﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Design;
using System.Drawing.Drawing2D;
using System.Reflection;
using System.Windows.Forms;
using HML.Design;

namespace HML
{
    /// <summary>
    /// 日期面板控件
    /// </summary>
    [Description("日期面板控件")]
    [DefaultProperty("DateValue")]
    [DefaultEvent("BottomBarConfirmClick")]
    [TypeConverter(typeof(DatePickerConverter))]
    [Designer(typeof(DatePickerDesigner))]
    [ToolboxItem(true)]
    [ToolboxBitmap(typeof(DatePicker), "Controls.DatePicker.Resources.DatePicker.bmp")]
    public class DatePicker : DpiControl, ISkinObject
    {
        #region 主题

        private SkinObjectXmlMetadata skinObjectXmlMetadata = null;
        /// <summary>
        /// 主题对象在主题文件信息
        /// </summary>
        [Browsable(false)]
        [EditorBrowsable(EditorBrowsableState.Never)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
        public virtual SkinObjectXmlMetadata SkinObjectXmlMetadata
        {
            get
            {
                if (this.skinObjectXmlMetadata == null)
                    this.skinObjectXmlMetadata = new SkinObjectXmlMetadata(Assembly.GetAssembly(typeof(DatePicker)).GetName().Name, typeof(DatePicker).Name);

                return this.skinObjectXmlMetadata;
            }
        }

        private SkinController skinController = null;
        /// <summary>
        /// 主题控制器
        /// </summary>
        [Description("主题控制器")]
        [Category("杂项")]
        [PropertyOrder(-360)]
        [DefaultValue(null)]
        [RefreshProperties(RefreshProperties.All)]
        public virtual SkinController SkinController
        {
            get { return this.skinController; }
            set
            {
                if (this.skinController == value)
                    return;

                if (this.skinController != null)
                    this.skinController.RemoveSkinObject(this);

                this.skinController = value;

                if (this.skinController != null)
                    this.skinController.AddSkinObject(this);
            }
        }

        private SkinEnabledState skinEnabled= SkinEnabledState.Auto;
        /// <summary>
        /// 主题是否启用
        /// </summary>
        [Description("主题是否启用")]
        [Category("杂项")]
        [PropertyOrder(-300)]
        [DefaultValue(SkinEnabledState.Auto)]
        [RefreshProperties(RefreshProperties.All)]
        public virtual SkinEnabledState SkinEnabled
        {
            get { return this.skinEnabled; }
            set
            {
                if (this.skinEnabled == value)
                    return;

                this.skinEnabled = value;
                this.OnSkinChanged();
            }
        }

        private SkinStyle skinStyle = SkinStyle.Normal;
        /// <summary>
        /// 主题风格
        /// </summary>
        [Description("主题风格")]
        [Category("杂项")]
        [PropertyOrder(-260)]
        [DefaultValue(SkinStyle.Normal)]
        [RefreshProperties(RefreshProperties.All)]
        public virtual SkinStyle SkinStyle
        {
            get { return this.skinStyle; }
            set
            {
                if (this.skinStyle == value)
                    return;

                this.skinStyle = value;
                this.OnSkinChanged();
            }
        }

        private StyleAppearanceObject stateAppearance;
        /// <summary>
        ///外观
        /// </summary>
        [Description("风格外观")]
        [PropertyOrder(-200)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
        public StyleAppearanceObject StyleAppearance
        {
            get
            {
                if (this.stateAppearance == null)
                    this.stateAppearance = new StyleAppearanceObject(this, null);
                return this.stateAppearance;
            }
        }

        /// <summary>
        /// 主题已更改
        /// </summary>
        public virtual void OnSkinChanged()
        {
            SkinManager.SyncSkinValueToProperty(this);
            this.Invalidate();
        }

        private ISkinObject followSkinObject = null;
        /// <summary>
        /// 主题设置跟随指定主题对象（自己的设置不再生效，提供给代码使用）
        /// </summary>
        [Browsable(false)]
        [EditorBrowsable(EditorBrowsableState.Never)]
        [Localizable(false)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
        public virtual ISkinObject FollowSkinObject
        {
            get { return this.followSkinObject; }
            set
            {
                if (this.followSkinObject == value)
                    return;

                this.followSkinObject = value;
                this.OnSkinChanged();
            }
        }

        public virtual bool GetSkinObjectSkinStateCore()
        {
            return SkinManager.GetSkinObjectSkinState(this.FollowSkinObject ?? this);
        }

        void ISkinObject.InitializeInvalidate()
        {
            throw new NotImplementedException();
        }

        void ISkinObject.Invalidate()
        {
            this.Invalidate();
        }

        #endregion

        #region 新增事件

        private static readonly object EventBottomBarClearClick = new object();
        /// <summary>
        /// 底部工具栏清除单击事件
        /// </summary>
        [Description("底部工具栏清除单击事件")]
        public event EventHandler BottomBarClearClick
        {
            add { Events.AddHandler(EventBottomBarClearClick, value); }
            remove { Events.RemoveHandler(EventBottomBarClearClick, value); }
        }

        private static readonly object EventBottomBarNowClick = new object();
        /// <summary>
        /// 底部工具栏现在单击事件
        /// </summary>
        [Description("底部工具栏现在单击事件")]
        public event EventHandler BottomBarNowClick
        {
            add { Events.AddHandler(EventBottomBarNowClick, value); }
            remove { Events.RemoveHandler(EventBottomBarNowClick, value); }
        }

        private static readonly object EventBottomBarConfirmClick = new object();
        /// <summary>
        /// 底部工具栏确认单击事件
        /// </summary>
        [Description("底部工具栏确认单击事件")]
        public event EventHandler BottomBarConfirmClick
        {
            add { Events.AddHandler(EventBottomBarConfirmClick, value); }
            remove { Events.RemoveHandler(EventBottomBarConfirmClick, value); }
        }

        private static readonly object EventDateValueChanged = new object();
        /// <summary>
        /// 日期值更改事件
        /// </summary>
        [Description("日期值更改事件")]
        public event EventHandler DateValueChanged
        {
            add { Events.AddHandler(EventDateValueChanged, value); }
            remove { Events.RemoveHandler(EventDateValueChanged, value); }
        }

        private static readonly object EventDateFormatChanged = new object();
        /// <summary>
        /// 日期显示格式更改事件
        /// </summary>
        [Description("日期显示格式更改事件")]
        public event EventHandler DateFormatChanged
        {
            add { Events.AddHandler(EventDateFormatChanged, value); }
            remove { Events.RemoveHandler(EventDateFormatChanged, value); }
        }

        #endregion

        #region 停用事件

        [Browsable(false)]
        [EditorBrowsable(EditorBrowsableState.Never)]
        public new event EventHandler DockChanged
        {
            add { base.DockChanged += value; }
            remove { base.DockChanged -= value; }
        }

        [Browsable(false)]
        [EditorBrowsable(EditorBrowsableState.Never)]
        public new event EventHandler PaddingChanged
        {
            add { base.PaddingChanged += value; }
            remove { base.PaddingChanged -= value; }
        }

        [Browsable(false)]
        [EditorBrowsable(EditorBrowsableState.Never)]
        public new event EventHandler BackgroundImageChanged
        {
            add { base.BackgroundImageChanged += value; }
            remove { base.BackgroundImageChanged -= value; }
        }

        [Browsable(false)]
        [EditorBrowsable(EditorBrowsableState.Never)]
        public new event EventHandler BackgroundImageLayoutChanged
        {
            add { base.BackgroundImageLayoutChanged += value; }
            remove { base.BackgroundImageLayoutChanged -= value; }
        }

        [Browsable(false)]
        [EditorBrowsable(EditorBrowsableState.Never)]
        public new event EventHandler TextChanged
        {
            add { base.TextChanged += value; }
            remove { base.TextChanged -= value; }
        }

        [Browsable(false)]
        [EditorBrowsable(EditorBrowsableState.Never)]
        public new event EventHandler FontChanged
        {
            add { base.FontChanged += value; }
            remove { base.FontChanged -= value; }
        }

        [Browsable(false)]
        [EditorBrowsable(EditorBrowsableState.Never)]
        public new event EventHandler RightToLeftChanged
        {
            add { base.RightToLeftChanged += value; }
            remove { base.RightToLeftChanged -= value; }
        }

        [Browsable(false)]
        [EditorBrowsable(EditorBrowsableState.Never)]
        public new event EventHandler ImeModeChanged
        {
            add { base.ImeModeChanged += value; }
            remove { base.ImeModeChanged -= value; }
        }

        [Browsable(false)]
        [EditorBrowsable(EditorBrowsableState.Never)]
        public new event EventHandler BackColorChanged
        {
            add { base.BackColorChanged += value; }
            remove { base.BackColorChanged -= value; }
        }

        [Browsable(false)]
        [EditorBrowsable(EditorBrowsableState.Never)]
        public new event EventHandler ForeColorChanged
        {
            add { base.ForeColorChanged += value; }
            remove { base.ForeColorChanged -= value; }
        }

        [Browsable(false)]
        [EditorBrowsable(EditorBrowsableState.Never)]
        public new event EventHandler Click
        {
            add { base.Click += value; }
            remove { base.Click -= value; }
        }

        [Browsable(false)]
        [EditorBrowsable(EditorBrowsableState.Never)]
        public new event EventHandler DoubleClick
        {
            add { base.DoubleClick += value; }
            remove { base.DoubleClick -= value; }
        }

        [Browsable(false)]
        [EditorBrowsable(EditorBrowsableState.Never)]
        public new event MouseEventHandler MouseClick
        {
            add { base.MouseClick += value; }
            remove { base.MouseClick -= value; }
        }

        [Browsable(false)]
        [EditorBrowsable(EditorBrowsableState.Never)]
        public new event MouseEventHandler MouseDoubleClick
        {
            add { base.MouseDoubleClick += value; }
            remove { base.MouseDoubleClick -= value; }
        }

        #endregion

        #region 新增属性

        private bool borderVisible = false;
        /// <summary>
        ///是否显示边框
        /// </summary>
        [Description("是否显示边框")]
        [Category("杂项")]
        [PropertyOrder(-198)]
        [DefaultValue(false)]
        public bool BorderVisible
        {
            get { return this.borderVisible; }
            set
            {
                if (this.borderVisible == value)
                    return;

                this.borderVisible = value;
                this.Invalidate();
            }
        }

        private bool bottomBarMinMaxTipVisible = true;
        /// <summary>
        /// 是否显示最小值最大值限制提示信息
        /// </summary>
        [Description("是否显示最小值最大值限制提示信息")]
        [PropertyOrder(-196)]
        [DefaultValue(true)]
        public bool BottomBarMinMaxTipVisible
        {
            get { return this.bottomBarMinMaxTipVisible; }
            set
            {
                if (this.bottomBarMinMaxTipVisible == value)
                    return;

                this.bottomBarMinMaxTipVisible = value;
                this.UpdateBottomText();
                this.Invalidate();
            }
        }

        private bool readOnly = false;
        /// <summary>
        /// 是否只读
        /// </summary>
        [Description("是否只读")]
        [Category("杂项")]
        [PropertyOrder(-194)]
        [DefaultValue(false)]
        public bool ReadOnly
        {
            get { return this.readOnly; }
            set
            {
                if (this.readOnly == value)
                    return;

                this.readOnly = value;
                IContainerControl c = this.Parent.GetContainerControl();
                if (c != null)
                {
                    ((Control)c).SelectNextControl(this, true, true, true, true);
                }
                this.InitializeViewForDateValue();
            }
        }

        private DatePickerFormats dateFormat = DatePickerFormats.yyyyMMddHHmmss;
        /// <summary>
        /// 日期显示格式（自动截取到显示部分）
        /// </summary>
        [Description("日期显示格式（自动截取到显示部分）")]
        [Category("杂项")]
        [PropertyOrder(-192)]
        [DefaultValue(DatePickerFormats.yyyyMMddHHmmss)]
        [Bindable(true)]
        public DatePickerFormats DateFormat
        {
            get { return this.dateFormat; }
            set
            {
                if (this.dateFormat == value)
                    return;

                this.dateFormat = value;

                if (this.DateFormat == DatePickerFormats.yyyy)
                {
                    this.SetCurrentDateFormatsViews(DateFormatsViews.Year_Year);
                }
                else if (this.DateFormat == DatePickerFormats.yyyyMM)
                {
                    this.SetCurrentDateFormatsViews(DateFormatsViews.YearMonth_Month);
                }
                else
                {
                    this.SetCurrentDateFormatsViews(DateFormatsViews.YearMonthDay_Day);
                }

                this.Size = this.GetControlAutoSize();
                this.InitializeViewForDateValue();

                this.OnDateFormatChanged(new EventArgs());
            }
        }

        private DateTime minValue = minDate;
        /// <summary>
        /// 最小日期(只比较日期部分)
        /// </summary>
        [Description("最小日期(只比较日期部分)")]
        [Category("杂项")]
        [PropertyOrder(-190)]
        [DefaultValue(typeof(DateTime), "1753,1,1")]
        public DateTime MinValue
        {
            get { return this.minValue; }
            set
            {
                if (this.minValue.Date == value.Date)
                    return;

                if (value.Date > this.MaxValue)
                {
                    throw new ArgumentOutOfRangeException("“MinDate”应小于等于 'MaxValue' ");
                }
                if (this.dateValue.HasValue && value.Date > this.dateValue.Value.Date)
                {
                    throw new ArgumentOutOfRangeException("“MinDate”应小于等于 'DateValue'");
                }

                this.minValue = value.Date;
                this.UpdateYearMonthDayText();
                this.UpdateBottomText();
                this.Invalidate();
            }
        }

        private DateTime maxValue = maxDate;
        /// <summary>
        /// 最大日期(只比较日期部分)
        /// </summary>
        [Description("最大日期(只比较日期部分)")]
        [Category("杂项")]
        [PropertyOrder(-188)]
        [DefaultValue(typeof(DateTime), "9998,12,31")]
        public DateTime MaxValue
        {
            get { return this.maxValue; }
            set
            {
                if (this.maxValue.Date == value.Date)
                    return;

                if (value.Date < this.MinValue)
                {
                    throw new ArgumentOutOfRangeException("“MaxValue”应大于等于 'MinDate' ");
                }
                if (this.dateValue.HasValue && value.Date < this.dateValue.Value.Date)
                {
                    throw new ArgumentOutOfRangeException("“MaxDate”应大于等于 'DateValue'");
                }

                this.maxValue = value.Date;
                this.UpdateYearMonthDayText();
                this.UpdateBottomText();
                this.Invalidate();
            }
        }

        private DateTime? dateValue = null;
        /// <summary>
        /// 日期 (获取时自动根据 DateFormat 属性对日期时间进行截取)
        /// </summary>
        [Description("日期 (获取时自动根据 DateFormat 属性对日期时间进行截取)")]
        [Category("杂项")]
        [PropertyOrder(-186)]
        [DefaultValue(null)]
        [Bindable(true)]
        public DateTime? DateValue
        {
            get
            {
                if (this.dateValue.HasValue == false)
                {
                    return this.dateValue;
                }
                else if (this.DateFormat == DatePickerFormats.yyyy)
                {
                    return new DateTime(this.dateValue.Value.Year, 1, 1, 0, 0, 0);
                }
                else if (this.DateFormat == DatePickerFormats.yyyyMM)
                {
                    return new DateTime(this.dateValue.Value.Year, this.dateValue.Value.Month, 1, 0, 0, 0);
                }
                else if (this.DateFormat == DatePickerFormats.yyyyMMdd)
                {
                    return this.dateValue.Value.Date;
                }
                else if (this.DateFormat == DatePickerFormats.yyyyMMddHH)
                {
                    return new DateTime(this.dateValue.Value.Year, this.dateValue.Value.Month, this.dateValue.Value.Day, this.dateValue.Value.Hour, 0, 0);
                }
                else if (this.DateFormat == DatePickerFormats.yyyyMMddHHmm)
                {
                    return new DateTime(this.dateValue.Value.Year, this.dateValue.Value.Month, this.dateValue.Value.Day, this.dateValue.Value.Hour, this.dateValue.Value.Minute, 0);
                }
                else
                {
                    return this.dateValue.Value;
                }
            }
            set
            {
                if (this.dateValue == value)
                    return;

                if (value.HasValue && (this.MinValue > value.Value.Date || value.Value.Date > this.MaxValue))
                {
                    throw new ArgumentOutOfRangeException("“DateValue”应介于 'MinDate' 和 'MaxDate' 之间");
                }

                this.dateValue = value;

                this.InitializeViewForDateValue();

                this.OnDateValueChanged(new EventArgs());
            }
        }

        #endregion

        #region 重写属性

        protected override Size DefaultSize
        {
            get { return new Size(226, 298); }
        }

        [DefaultValue("")]
        public new string Name
        {
            get { return base.Name; }
            set { base.Name = value; }
        }

        [DefaultValue(typeof(Point), "0,0")]
        public new Point Location
        {
            get { return base.Location; }
            set { base.Location = value; }
        }

        [DefaultValue(0)]
        public new int TabIndex
        {
            get { return base.TabIndex; }
            set { base.TabIndex = value; }
        }

        #endregion

        #region 停用属性

        [Browsable(false)]
        [EditorBrowsable(EditorBrowsableState.Never)]
        public override DockStyle Dock
        {
            get { return base.Dock; }
            set { base.Dock = value; }
        }

        [Browsable(false)]
        [EditorBrowsable(EditorBrowsableState.Never)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
        public new Padding Padding
        {
            get { return base.Padding; }
            set { base.Padding = value; }
        }

        [Browsable(false)]
        [EditorBrowsable(EditorBrowsableState.Never)]
        public new Image BackgroundImage
        {
            get { return base.BackgroundImage; }
            set { base.BackgroundImage = value; }
        }

        [Browsable(false)]
        [EditorBrowsable(EditorBrowsableState.Never)]
        public new ImageLayout BackgroundImageLayout
        {
            get { return base.BackgroundImageLayout; }
            set { base.BackgroundImageLayout = value; }
        }

        [Bindable(false)]
        [Browsable(false)]
        [EditorBrowsable(EditorBrowsableState.Never)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
        public override string Text
        {
            get { return base.Text; }
            set { base.Text = value; }
        }

        [Browsable(false)]
        [EditorBrowsable(EditorBrowsableState.Never)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
        [Localizable(false)]
        public override Font Font
        {
            get { return base.Font; }
            set { base.Font = value; }
        }

        [Browsable(false)]
        [EditorBrowsable(EditorBrowsableState.Never)]
        public override RightToLeft RightToLeft
        {
            get { return base.RightToLeft; }
            set { base.RightToLeft = value; }
        }

        [Browsable(false)]
        [EditorBrowsable(EditorBrowsableState.Never)]
        public new ImeMode ImeMode
        {
            get { return base.ImeMode; }
            set { base.ImeMode = value; }
        }

        [Browsable(false)]
        [EditorBrowsable(EditorBrowsableState.Never)]
        public new Size Size
        {
            get { return base.Size; }
            set { base.Size = value; }
        }

        [Browsable(false)]
        [EditorBrowsable(EditorBrowsableState.Never)]
        public override Size MinimumSize
        {
            get { return base.MinimumSize; }
            set { base.MinimumSize = value; }
        }

        [Browsable(false)]
        [EditorBrowsable(EditorBrowsableState.Never)]
        public override Size MaximumSize
        {
            get { return base.MaximumSize; }
            set { base.MaximumSize = value; }
        }

        [Browsable(false)]
        [EditorBrowsable(EditorBrowsableState.Never)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
        public override Color BackColor
        {
            get { return this.StyleAppearance.BackColor; }
            set { }
        }

        [Browsable(false)]
        [EditorBrowsable(EditorBrowsableState.Never)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
        public override Color ForeColor
        {
            get { return this.StyleAppearance.Date.Normal.TextColor; }
            set { }
        }

        #endregion

        #region 字段

        /// <summary>
        /// 激活选项索引:
        /// 年面板.激活选项索引(年功能下：-2至14)(年月功能下： -3至14)(年月日功能下：-6至14)
        /// 月面板.激活选项索引(年月功能下： -3至14)(年月日功能下：-6至14)
        /// 日面板.激活选项索引(年月日功能下：-6至44)
        /// </summary>
        private int activatedIndex = 0;
        /// <summary>
        /// 激活选项区域
        /// </summary>
        private Rectangle? activatedrect = null;
        /// <summary>
        /// 激活选项是否显示
        /// </summary>
        private bool activatedVisible = false;

        /// <summary>
        /// 最小日期
        /// </summary>
        private static readonly DateTime minDate = new DateTime(1753, 1, 1).Date;
        /// <summary>
        /// 最大日期
        /// </summary>
        private static readonly DateTime maxDate = new DateTime(9998, 12, 31).Date;

        /// <summary>
        /// 顶部工具栏高度
        /// </summary>
        private readonly int topbar_rect_height = 36;
        /// <summary>
        /// 主体面板宽度
        /// </summary>
        private readonly int mainbar_rect_width = 226;
        /// <summary>
        /// 主体面板高度
        /// </summary>
        private readonly int mainbar_rect_height = 226;
        /// <summary>
        /// 底部工具栏高度
        /// </summary>
        private readonly int bottombar_rect_height = 36;
        /// <summary>
        /// 年选项宽度
        /// </summary>
        private readonly int year_item_rect_width = 66;
        /// <summary>
        /// 年选项高度
        /// </summary>
        private readonly int year_item_rect_height = 36;
        /// <summary>
        /// 月选项宽度
        /// </summary>
        private readonly int month_item_rect_width = 66;
        /// <summary>
        /// 月选项高度
        /// </summary>
        private readonly int month_item_rect_height = 36;
        /// <summary>
        /// 日选项宽度
        /// </summary>
        private readonly int day_item_rect_width = 30;
        /// <summary>
        /// 日选项高度
        /// </summary>
        private readonly int day_item_rect_height = 30;
        /// <summary>
        /// 日期面板和时间面板间隔
        /// </summary>
        private int date_time_rect_space = 1;
        /// <summary>
        /// 时间选项宽度
        /// </summary>
        private int time_item_rect_width = 50;
        /// <summary>
        /// 时间选项高度
        /// </summary>
        private int time_item_rect_height = 26;
        /// <summary>
        /// 时间滚动条厚度
        /// </summary>
        private int time_scroll_thickness = 9;

        /// <summary>
        /// 存放日期元素信息对象
        /// </summary>
        private DateBodyClass dateBody;
        /// <summary>
        /// 当前显示的日期面板
        /// </summary>
        private DateFormatsViews currentDateFormatsViews = DateFormatsViews.YearMonthDay_Day;
        /// <summary>
        /// 鼠标按下对象
        /// </summary>
        private object mousedownobject = null;
        /// <summary>
        /// 鼠标按下坐标
        /// </summary>
        private Point mousedownpoint = Point.Empty;

        /// <summary>
        /// 鼠标进入对象
        /// </summary>
        private object mouseenterobject = null;

        private readonly static Font mianFont = new Font("微软雅黑", 10);

        #endregion

        public DatePicker()
        {
            SetStyle(ControlStyles.UserPaint, true);
            SetStyle(ControlStyles.AllPaintingInWmPaint, true);
            SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
            SetStyle(ControlStyles.ResizeRedraw, true);
            SetStyle(ControlStyles.StandardClick, false);//自定义单击事件逻辑
            SetStyle(ControlStyles.StandardDoubleClick, false);//停用双加事件

            this.SuspendLayout();
            this.dateBody = new DateBodyClass();
            this.Font = mianFont;
            this.InitializeLayoutRectangle();
            this.InitializeViewForDateValue();
            this.OnSkinChanged();
            this.ResumeLayout();

        }

        #region 重写

        protected override void OnScaleDpiChangedInitialize()
        {
            this.InitializeLayoutRectangle();
            this.InitializeViewForDateValue();
        }

        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            Graphics g = e.Graphics;
            StringFormat text_center_sf = (StringFormat)StringFormat.GenericTypographic.Clone();
            text_center_sf.Alignment = StringAlignment.Center;
            text_center_sf.LineAlignment = StringAlignment.Center;

            SolidBrush commom_sb = new SolidBrush(Color.White);
            Pen common_crossline_pen = new Pen(this.StyleAppearance.CrossLineColor, 1);
            Pen topbar_btn_fore_normal_pen = new Pen(this.StyleAppearance.TopBar.Button.Normal.ForeColor, (this.ScaleDpi) >= 1.5 ? 2 : 1);
            Pen topbar_btn_fore_enter_pen = new Pen(this.StyleAppearance.TopBar.Button.Enter.ForeColor, (this.ScaleDpi) >= 1.5 ? 2 : 1);

            #region 顶部工具栏
            commom_sb.Color = this.StyleAppearance.TopBar.BackColor;
            g.FillRectangle(commom_sb, this.dateBody.TopBar_Rect);
            g.DrawLine(common_crossline_pen, this.dateBody.TopBar_Rect.X, this.dateBody.TopBar_Rect.Bottom - 1, this.dateBody.TopBar_Rect.Right, this.dateBody.TopBar_Rect.Bottom - 1);

            if (this.currentDateFormatsViews == DateFormatsViews.Year_Year)
            {
                commom_sb.Color = this.StyleAppearance.TopBar.Button.Normal.ForeColor;
                g.DrawString(this.dateBody.TopBar_yearscope_btn.Text, this.Font, commom_sb, this.dateBody.TopBar_yearscope_btn.Rect, text_center_sf);
            }

            if (this.currentDateFormatsViews == DateFormatsViews.YearMonth_Year || this.currentDateFormatsViews == DateFormatsViews.YearMonth_Month)
            {
                commom_sb.Color = this.mouseenterobject == this.dateBody.TopBar_monthyear_btn ? this.StyleAppearance.TopBar.Button.Enter.ForeColor : this.StyleAppearance.TopBar.Button.Normal.ForeColor;
                g.DrawString(this.dateBody.TopBar_monthyear_btn.Text, this.Font, commom_sb, this.dateBody.TopBar_monthyear_btn.Rect, text_center_sf);
            }

            if (this.currentDateFormatsViews == DateFormatsViews.YearMonthDay_Year || this.currentDateFormatsViews == DateFormatsViews.YearMonthDay_Month || this.currentDateFormatsViews == DateFormatsViews.YearMonthDay_Day)
            {
                commom_sb.Color = this.mouseenterobject == this.dateBody.TopBar_month_btn ? this.StyleAppearance.TopBar.Button.Enter.ForeColor : this.StyleAppearance.TopBar.Button.Normal.ForeColor;
                g.DrawString(this.dateBody.TopBar_month_btn.Text, this.Font, commom_sb, this.dateBody.TopBar_month_btn.Rect, text_center_sf);
                commom_sb.Color = this.mouseenterobject == this.dateBody.TopBar_year_btn ? this.StyleAppearance.TopBar.Button.Enter.ForeColor : this.StyleAppearance.TopBar.Button.Normal.ForeColor;
                g.DrawString(this.dateBody.TopBar_year_btn.Text, this.Font, commom_sb, this.dateBody.TopBar_year_btn.Rect, text_center_sf);
            }

            SmoothingMode sm = g.SmoothingMode;
            g.SmoothingMode = SmoothingMode.AntiAlias;

            {
                //上一年
                g.DrawLines((this.mouseenterobject == this.dateBody.TopBar_prev_year_btn) ? topbar_btn_fore_enter_pen : topbar_btn_fore_normal_pen, this.dateBody.TopBar_prev_year_btn.LineLeftPointArr);
                g.DrawLines((this.mouseenterobject == this.dateBody.TopBar_prev_year_btn) ? topbar_btn_fore_enter_pen : topbar_btn_fore_normal_pen, this.dateBody.TopBar_prev_year_btn.LineRightPointArr);
                //下一年
                g.DrawLines((this.mouseenterobject == this.dateBody.TopBar_next_year_btn) ? topbar_btn_fore_enter_pen : topbar_btn_fore_normal_pen, this.dateBody.TopBar_next_year_btn.LineLeftPointArr);
                g.DrawLines((this.mouseenterobject == this.dateBody.TopBar_next_year_btn) ? topbar_btn_fore_enter_pen : topbar_btn_fore_normal_pen, this.dateBody.TopBar_next_year_btn.LineRightPointArr);
            }

            if (this.currentDateFormatsViews == DateFormatsViews.YearMonthDay_Year || this.currentDateFormatsViews == DateFormatsViews.YearMonthDay_Month || this.currentDateFormatsViews == DateFormatsViews.YearMonthDay_Day)
            {
                //上一月
                g.DrawLines((this.mouseenterobject == this.dateBody.TopBar_prev_month_btn) ? topbar_btn_fore_enter_pen : topbar_btn_fore_normal_pen, this.dateBody.TopBar_prev_month_btn.LineLeftPointArr);
                //下一月
                g.DrawLines((this.mouseenterobject == this.dateBody.TopBar_next_month_btn) ? topbar_btn_fore_enter_pen : topbar_btn_fore_normal_pen, this.dateBody.TopBar_next_month_btn.LineRightPointArr);
            }

            g.SmoothingMode = sm;

            string time_text = "";
            if (this.DateFormat == DatePickerFormats.yyyyMMddHH)
            {
                time_text = string.Format("{0}", this.dateBody.selected_hour.ToString().PadLeft(2, '0'));
            }
            else if (this.DateFormat == DatePickerFormats.yyyyMMddHHmm)
            {
                time_text = string.Format("{0}:{1}", this.dateBody.selected_hour.ToString().PadLeft(2, '0'), this.dateBody.selected_minute.ToString().PadLeft(2, '0'));
            }
            else if (this.DateFormat == DatePickerFormats.yyyyMMddHHmmss)
            {
                time_text = string.Format("{0}:{1}:{2}", this.dateBody.selected_hour.ToString().PadLeft(2, '0'), this.dateBody.selected_minute.ToString().PadLeft(2, '0'), this.dateBody.selected_second.ToString().PadLeft(2, '0'));
            }
            commom_sb.Color = this.StyleAppearance.TopBar.Button.Normal.ForeColor;
            g.DrawString(time_text, this.Font, commom_sb, this.dateBody.TopBar_Time_Rect, text_center_sf);
            #endregion

            //主面板
            commom_sb.Color = this.StyleAppearance.BackColor;
            g.FillRectangle(commom_sb, this.dateBody.MainBar_Rect);

            //年面板
            if (this.IsContainEmbodyForCurrentView(DateElement.Year))
            {
                int select_date = (this.dateBody.selected_year == -1) ? -1 : this.dateBody.selected_year;
                for (int i = 0; i < this.dateBody.YearMain_itemArr.Length; i++)
                {
                    string text = String.Format("{0}年", this.dateBody.YearMain_itemArr[i].Value.Substring(2, 4));
                    int tmp = int.Parse(this.dateBody.YearMain_itemArr[i].Value.Substring(2, 4));
                    Color back_color;
                    Color text_color;

                    //已选中
                    if (tmp == select_date)
                    {
                        back_color = this.StyleAppearance.Date.Selected.BackColor;
                        text_color = this.StyleAppearance.Date.Selected.TextColor;
                    }
                    //限制范围之外
                    else if (this.MinValue.Year > tmp || tmp > this.MaxValue.Year)
                    {
                        back_color = this.StyleAppearance.Date.Disabled.BackColor;
                        text_color = this.StyleAppearance.Date.Disabled.TextColor;
                    }
                    //鼠标进入
                    else if (this.mouseenterobject == this.dateBody.YearMain_itemArr[i])
                    {
                        back_color = this.StyleAppearance.Date.Enter.BackColor;
                        text_color = this.StyleAppearance.Date.Enter.TextColor;
                    }
                    else
                    {
                        back_color = this.StyleAppearance.Date.Normal.BackColor;
                        text_color = this.StyleAppearance.Date.Normal.TextColor;
                    }

                    if (back_color != Color.Empty)
                    {
                        commom_sb.Color = back_color;
                        g.FillRectangle(commom_sb, this.dateBody.YearMain_itemArr[i].Rect);
                    }
                    commom_sb.Color = text_color;
                    g.DrawString(text, this.Font, commom_sb, this.dateBody.YearMain_itemArr[i].Rect, text_center_sf);
                }
            }
            //月面板
            if (this.IsContainEmbodyForCurrentView(DateElement.Month))
            {
                int ym_min_month = int.Parse(this.MinValue.ToString("10yyyyMM"));
                int ym_max_month = int.Parse(this.MaxValue.ToString("10yyyyMM"));
                int select_date = (this.dateBody.selected_month == -1) ? -1 : int.Parse(("10" + this.dateBody.selected_year.ToString().PadLeft(4, '0') + this.dateBody.selected_month.ToString().PadLeft(2, '0')));
                for (int i = 0; i < this.dateBody.MonthMain_itemArr.Length; i++)
                {
                    string text = String.Format("{0}月", this.dateBody.MonthMain_itemArr[i].Value.Substring(6, 2));
                    int ym_now_month = int.Parse(this.dateBody.MonthMain_itemArr[i].Value);
                    Color back_color;
                    Color text_color;

                    //已选中
                    if (ym_now_month == select_date)
                    {
                        back_color = this.StyleAppearance.Date.Selected.BackColor;
                        text_color = this.StyleAppearance.Date.Selected.TextColor;
                    }
                    //限制范围之外
                    else if (ym_min_month > ym_now_month || ym_now_month > ym_max_month)
                    {
                        back_color = this.StyleAppearance.Date.Disabled.BackColor;
                        text_color = this.StyleAppearance.Date.Disabled.TextColor;
                    }
                    //鼠标进入
                    else if (this.mouseenterobject == this.dateBody.MonthMain_itemArr[i])
                    {
                        back_color = this.StyleAppearance.Date.Enter.BackColor;
                        text_color = this.StyleAppearance.Date.Enter.TextColor;
                    }
                    else
                    {
                        back_color = this.StyleAppearance.Date.Normal.BackColor;
                        text_color = this.StyleAppearance.Date.Normal.TextColor;
                    }

                    if (back_color != Color.Empty)
                    {
                        commom_sb.Color = back_color;
                        g.FillRectangle(commom_sb, this.dateBody.MonthMain_itemArr[i].Rect);
                    }
                    commom_sb.Color = text_color;
                    g.DrawString(text, this.Font, commom_sb, this.dateBody.MonthMain_itemArr[i].Rect, text_center_sf);

                }
            }
            //日面板
            if (this.IsContainEmbodyForCurrentView(DateElement.Day))
            {
                commom_sb.Color = this.StyleAppearance.Date.TitleTextColor;
                for (int i = 0; i < this.dateBody.DayMain_titleArr.Length; i++)
                {
                    g.DrawString(this.dateBody.DayMain_titleArr[i].Text, this.Font, commom_sb, this.dateBody.DayMain_titleArr[i].Rect, text_center_sf);
                }

                int select_date = (this.dateBody.selected_day == -1) ? -1 : int.Parse("10" + this.dateBody.selected_year.ToString().PadLeft(4, '0') + this.dateBody.selected_month.ToString().PadLeft(2, '0') + this.dateBody.selected_day.ToString().PadLeft(2, '0'));
                for (int i = 0; i < this.dateBody.DayMain_itemArr.Length; i++)
                {
                    string text = int.Parse(this.dateBody.DayMain_itemArr[i].Value.Substring(8, 2)).ToString();
                    int tmp = int.Parse(this.dateBody.DayMain_itemArr[i].Value);
                    Color back_color;
                    Color text_color;

                    //已选中
                    if (tmp == select_date)
                    {
                        back_color = this.StyleAppearance.Date.Selected.BackColor;
                        text_color = this.StyleAppearance.Date.Selected.TextColor;
                    }
                    //限制范围之外
                    else if (this.dateBody.DayMain_itemArr[i].DayItemType == DayItemTypes.Disabled)
                    {
                        back_color = this.StyleAppearance.Date.Disabled.BackColor;
                        text_color = this.StyleAppearance.Date.Disabled.TextColor;
                    }
                    //鼠标进入
                    else if (this.mouseenterobject == this.dateBody.DayMain_itemArr[i])
                    {
                        back_color = this.StyleAppearance.Date.Enter.BackColor;
                        text_color = this.StyleAppearance.Date.Enter.TextColor;
                    }
                    else
                    {
                        if (this.dateBody.DayMain_itemArr[i].DayItemType == DayItemTypes.UnCurrent)
                        {
                            back_color = this.StyleAppearance.Date.UnCurrent.BackColor;
                            text_color = this.StyleAppearance.Date.UnCurrent.TextColor;
                        }
                        else
                        {
                            back_color = this.StyleAppearance.Date.Normal.BackColor;
                            text_color = this.StyleAppearance.Date.Normal.TextColor;
                        }

                    }

                    if (back_color != Color.Empty)
                    {
                        commom_sb.Color = back_color;
                        g.FillRectangle(commom_sb, this.dateBody.DayMain_itemArr[i].Rect);
                    }
                    commom_sb.Color = text_color;
                    g.DrawString(text, this.Font, commom_sb, this.dateBody.DayMain_itemArr[i].Rect, text_center_sf);

                }

            }
            //时间面板
            if (this.IsContainEmbodyForCurrentFormat(DateElement.Hour))
            {
                //分割线
                ColorBlend splitter__cb = new ColorBlend();
                splitter__cb.Colors = new Color[] { Color.Transparent, this.StyleAppearance.CrossLineColor, this.StyleAppearance.CrossLineColor, Color.Transparent };
                splitter__cb.Positions = new float[] { 0.0f, 0.23f, 0.70f, 1.0f };
                LinearGradientBrush splitter_lgb = new LinearGradientBrush(new PointF(this.dateBody.TimeMain_Rect.X - this.date_time_rect_space, this.dateBody.TimeMain_Rect.Y), new PointF(this.dateBody.TimeMain_Rect.X - this.date_time_rect_space, this.dateBody.TimeMain_Rect.Bottom), Color.Transparent, Color.Transparent);
                splitter_lgb.InterpolationColors = splitter__cb;
                Pen splitter_pen = new Pen(splitter_lgb, this.date_time_rect_space);

                g.DrawLine(splitter_pen, new PointF(this.dateBody.TimeMain_Rect.X - this.date_time_rect_space, this.dateBody.TimeMain_Rect.Y), new PointF(this.dateBody.TimeMain_Rect.X - this.date_time_rect_space, this.dateBody.TimeMain_Rect.Bottom));

                splitter_pen.Dispose();
                splitter_lgb.Dispose();


                Region source_region = g.Clip;
                Region time_region = new Region(this.dateBody.TimeMain_Rect);
                g.Clip = time_region;

                int scale_timeScrollThickness = (int)(this.time_scroll_thickness * this.ScaleDpi);
                Pen scroll_track_pen = new Pen(this.StyleAppearance.ScrollBar.TrackBackColor, scale_timeScrollThickness);
                Pen scroll_thumb_pen = new Pen(this.StyleAppearance.ScrollBar.ThumbBackColor, scale_timeScrollThickness);
                //时
                if (this.IsContainEmbodyForCurrentFormat(DateElement.Hour))
                {
                    int y = this.GetTimeItemsDisplayY(this.dateBody.TimeMain_HourArea.Scroll);
                    for (int i = 0; i < this.dateBody.TimeMain_HourArea.itemArr.Length; i++)
                    {
                        if (this.dateBody.TimeMain_HourArea.itemArr[i].Rect.Bottom + y < this.dateBody.TimeMain_Rect.Y || this.dateBody.TimeMain_HourArea.itemArr[i].Rect.Y + y > this.dateBody.TimeMain_Rect.Bottom)
                        {
                            continue;
                        }
                        RectangleF item_rect = new RectangleF(this.dateBody.TimeMain_HourArea.itemArr[i].Rect.X, this.dateBody.TimeMain_HourArea.itemArr[i].Rect.Y + y, this.dateBody.TimeMain_HourArea.itemArr[i].Rect.Width, this.dateBody.TimeMain_HourArea.itemArr[i].Rect.Height);
                        Color back_color;
                        Color text_color;

                        if (this.dateBody.TimeMain_HourArea.itemArr[i].Value == this.dateBody.selected_hour)
                        {
                            back_color = this.StyleAppearance.Date.Selected.BackColor;
                            text_color = this.StyleAppearance.Date.Selected.TextColor;
                        }
                        else if (this.mouseenterobject == this.dateBody.TimeMain_HourArea.itemArr[i])
                        {
                            back_color = this.StyleAppearance.Date.Enter.BackColor;
                            text_color = this.StyleAppearance.Date.Enter.TextColor;
                        }
                        else
                        {
                            back_color = this.StyleAppearance.Date.Normal.BackColor;
                            text_color = this.StyleAppearance.Date.Normal.TextColor;
                        }

                        if (back_color != Color.Empty)
                        {
                            commom_sb.Color = back_color;
                            g.FillRectangle(commom_sb, item_rect);
                        }
                        commom_sb.Color = text_color;
                        g.DrawString(this.dateBody.TimeMain_HourArea.itemArr[i].Value.ToString().PadLeft(2, '0'), this.Font, commom_sb, item_rect, text_center_sf);

                    }
                    this.DrawTimeScroll(g, this.dateBody.TimeMain_HourArea.Scroll, scroll_track_pen, scroll_thumb_pen);
                }
                //分
                if (this.IsContainEmbodyForCurrentFormat(DateElement.Minute))
                {
                    int y = this.GetTimeItemsDisplayY(this.dateBody.TimeMain_MinuteArea.Scroll);
                    for (int i = 0; i < this.dateBody.TimeMain_MinuteArea.itemArr.Length; i++)
                    {
                        if (this.dateBody.TimeMain_MinuteArea.itemArr[i].Rect.Bottom + y < this.dateBody.TimeMain_Rect.Y || this.dateBody.TimeMain_MinuteArea.itemArr[i].Rect.Y + y > this.dateBody.TimeMain_Rect.Bottom)
                        {
                            continue;
                        }
                        RectangleF item_rect = new RectangleF(this.dateBody.TimeMain_MinuteArea.itemArr[i].Rect.X, this.dateBody.TimeMain_MinuteArea.itemArr[i].Rect.Y + y, this.dateBody.TimeMain_MinuteArea.itemArr[i].Rect.Width, this.dateBody.TimeMain_MinuteArea.itemArr[i].Rect.Height);
                        Color back_color;
                        Color text_color;

                        if (this.dateBody.TimeMain_MinuteArea.itemArr[i].Value == this.dateBody.selected_minute)
                        {
                            back_color = this.StyleAppearance.Date.Selected.BackColor;
                            text_color = this.StyleAppearance.Date.Selected.TextColor;
                        }
                        else if (this.mouseenterobject == this.dateBody.TimeMain_MinuteArea.itemArr[i])
                        {
                            back_color = this.StyleAppearance.Date.Enter.BackColor;
                            text_color = this.StyleAppearance.Date.Enter.TextColor;
                        }
                        else
                        {
                            back_color = this.StyleAppearance.Date.Normal.BackColor;
                            text_color = this.StyleAppearance.Date.Normal.TextColor;
                        }

                        if (back_color != Color.Empty)
                        {
                            commom_sb.Color = back_color;
                            g.FillRectangle(commom_sb, item_rect);
                        }
                        commom_sb.Color = text_color;
                        g.DrawString(this.dateBody.TimeMain_MinuteArea.itemArr[i].Value.ToString().PadLeft(2, '0'), this.Font, commom_sb, item_rect, text_center_sf);

                    }
                    this.DrawTimeScroll(g, this.dateBody.TimeMain_MinuteArea.Scroll, scroll_track_pen, scroll_thumb_pen);
                }
                //秒
                if (this.IsContainEmbodyForCurrentFormat(DateElement.Second))
                {
                    int y = this.GetTimeItemsDisplayY(this.dateBody.TimeMain_SecondArea.Scroll);
                    for (int i = 0; i < this.dateBody.TimeMain_SecondArea.itemArr.Length; i++)
                    {
                        if (this.dateBody.TimeMain_SecondArea.itemArr[i].Rect.Bottom + y < this.dateBody.TimeMain_Rect.Y || this.dateBody.TimeMain_SecondArea.itemArr[i].Rect.Y + y > this.dateBody.TimeMain_Rect.Bottom)
                        {
                            continue;
                        }

                        RectangleF item_rect = new RectangleF(this.dateBody.TimeMain_SecondArea.itemArr[i].Rect.X, this.dateBody.TimeMain_SecondArea.itemArr[i].Rect.Y + y, this.dateBody.TimeMain_SecondArea.itemArr[i].Rect.Width, this.dateBody.TimeMain_SecondArea.itemArr[i].Rect.Height);
                        Color back_color;
                        Color text_color;

                        if (this.dateBody.TimeMain_SecondArea.itemArr[i].Value == this.dateBody.selected_second)
                        {
                            back_color = this.StyleAppearance.Date.Selected.BackColor;
                            text_color = this.StyleAppearance.Date.Selected.TextColor;
                        }
                        else if (this.mouseenterobject == this.dateBody.TimeMain_SecondArea.itemArr[i])
                        {
                            back_color = this.StyleAppearance.Date.Enter.BackColor;
                            text_color = this.StyleAppearance.Date.Enter.TextColor;
                        }
                        else
                        {
                            back_color = this.StyleAppearance.Date.Normal.BackColor;
                            text_color = this.StyleAppearance.Date.Normal.TextColor;
                        }

                        if (back_color != Color.Empty)
                        {
                            commom_sb.Color = back_color;
                            g.FillRectangle(commom_sb, item_rect);
                        }
                        commom_sb.Color = text_color;
                        g.DrawString(this.dateBody.TimeMain_SecondArea.itemArr[i].Value.ToString().PadLeft(2, '0'), this.Font, commom_sb, item_rect, text_center_sf);
                    }
                    this.DrawTimeScroll(g, this.dateBody.TimeMain_SecondArea.Scroll, scroll_track_pen, scroll_thumb_pen);
                }

                scroll_track_pen.Dispose();
                scroll_thumb_pen.Dispose();

                g.Clip = source_region;
            }


            //底部工具栏边框
            commom_sb.Color = this.StyleAppearance.BottomBar.BackColor;
            g.FillRectangle(commom_sb, this.dateBody.BottomBar_Rect);
            g.DrawLine(common_crossline_pen, this.dateBody.BottomBar_Rect.X, this.dateBody.BottomBar_Rect.Y, this.dateBody.BottomBar_Rect.Right, this.dateBody.BottomBar_Rect.Y);

            if (this.BottomBarMinMaxTipVisible)
            {
                Pen bottombar_tip_line_pen = new Pen(this.StyleAppearance.BottomBar.MinMaxTipColor, (this.ScaleDpi >= 1.5) ? 3 : 1);
                g.DrawLines(bottombar_tip_line_pen, this.dateBody.Bottombar_minmaxborder_lab.LinePointArr);
                bottombar_tip_line_pen.Dispose();

                SolidBrush bottombar_tip_sb = new SolidBrush(this.StyleAppearance.BottomBar.MinMaxTipColor);
                g.DrawString(this.dateBody.Bottombar_mindate_lab.Text, this.Font, bottombar_tip_sb, this.dateBody.Bottombar_mindate_lab.Rect.Location, StringFormat.GenericTypographic);
                g.DrawString(this.dateBody.Bottombar_maxdate_lab.Text, this.Font, bottombar_tip_sb, this.dateBody.Bottombar_maxdate_lab.Rect.Location, StringFormat.GenericTypographic);
                bottombar_tip_sb.Dispose();
            }

            this.DrawLeftBorder(g, this.dateBody.Bottombar_clear_btn.Rect, (this.mouseenterobject == this.dateBody.Bottombar_clear_btn ? this.StyleAppearance.BottomBar.Button.Enter.BackColor : this.StyleAppearance.BottomBar.Button.Normal.BackColor), this.StyleAppearance.BottomBar.BackColor);
            commom_sb.Color = this.mouseenterobject == this.dateBody.Bottombar_clear_btn ? this.StyleAppearance.BottomBar.Button.Enter.TextColor : this.StyleAppearance.BottomBar.Button.Normal.TextColor;
            g.DrawString(this.dateBody.Bottombar_clear_btn.Text, this.Font, commom_sb, this.dateBody.Bottombar_clear_btn.Rect, text_center_sf);

            commom_sb.Color = this.mouseenterobject == this.dateBody.Bottombar_now_btn ? this.StyleAppearance.BottomBar.Button.Enter.BackColor : this.StyleAppearance.BottomBar.Button.Normal.BackColor;
            g.FillRectangle(commom_sb, this.dateBody.Bottombar_now_btn.Rect);
            commom_sb.Color = this.mouseenterobject == this.dateBody.Bottombar_now_btn ? this.StyleAppearance.BottomBar.Button.Enter.TextColor : this.StyleAppearance.BottomBar.Button.Normal.TextColor;
            g.DrawString(this.dateBody.Bottombar_now_btn.Text, this.Font, commom_sb, this.dateBody.Bottombar_now_btn.Rect, text_center_sf);

            this.DrawRightBorder(g, this.dateBody.Bottombar_confirm_btn.Rect, (this.mouseenterobject == this.dateBody.Bottombar_confirm_btn ? this.StyleAppearance.BottomBar.Button.Enter.BackColor : this.StyleAppearance.BottomBar.Button.Normal.BackColor), this.StyleAppearance.BottomBar.BackColor);
            commom_sb.Color = this.mouseenterobject == this.dateBody.Bottombar_confirm_btn ? this.StyleAppearance.BottomBar.Button.Enter.TextColor : this.StyleAppearance.BottomBar.Button.Normal.TextColor;
            g.DrawString(this.dateBody.Bottombar_confirm_btn.Text, this.Font, commom_sb, this.dateBody.Bottombar_confirm_btn.Rect, text_center_sf);

            // 控件激活的虚线
            if (this.Enabled && this.TabStop && this.Focused && this.activatedrect.HasValue && this.activatedVisible)
            {
                Pen activate_border_pen = new Pen(this.StyleAppearance.ActivateColor, 1) { DashStyle = DashStyle.Dash };
                g.DrawRectangle(activate_border_pen, this.activatedrect.Value.X, this.activatedrect.Value.Y, this.activatedrect.Value.Width - 1, this.activatedrect.Value.Height - 1);
                activate_border_pen.Dispose();
            }

            // 边框
            if (this.BorderVisible)
            {
                Pen border_pen = new Pen(this.StyleAppearance.BorderColor, 1);
                g.DrawRectangle(border_pen, new Rectangle(this.ClientRectangle.X, this.ClientRectangle.Y, this.ClientRectangle.Width - 1, this.ClientRectangle.Height - 1));
                border_pen.Dispose();
            }


            text_center_sf.Dispose();
            commom_sb.Dispose();
            common_crossline_pen.Dispose();
            topbar_btn_fore_normal_pen.Dispose();
            topbar_btn_fore_enter_pen.Dispose();
        }

        protected override void OnGotFocus(EventArgs e)
        {
            base.OnGotFocus(e);

            if (this.ReadOnly)
            {
                IContainerControl c = this.Parent.GetContainerControl();
                if (c != null)
                {
                    ((Control)c).SelectNextControl(this, true, true, true, true);
                }
                return;
            }

            this.SetCurrentDateFormatsViews(this.currentDateFormatsViews);
            this.activatedVisible = true;
            this.mousedownobject = null;
            this.mousedownpoint = Point.Empty;
            this.Invalidate();
        }

        protected override void OnLostFocus(EventArgs e)
        {
            base.OnLostFocus(e);

            this.mousedownobject = null;
            this.mousedownpoint = Point.Empty;
            this.Invalidate();
        }

        protected override void OnEnabledChanged(EventArgs e)
        {
            base.OnEnabledChanged(e);

            if (!this.Enabled)
            {
                this.mousedownobject = null;
                this.mousedownpoint = Point.Empty;
                this.Invalidate();
            }
        }

        protected override void OnVisibleChanged(EventArgs e)
        {
            base.OnVisibleChanged(e);

            if (!this.Visible)
            {
                this.mousedownobject = null;
                this.mousedownpoint = Point.Empty;
                this.Invalidate();
            }
        }

        protected override void OnParentChanged(EventArgs e)
        {
            base.OnParentChanged(e);

            if (this.Parent == null)
            {
                this.mousedownobject = null;
                this.mousedownpoint = Point.Empty;
                this.Invalidate();
            }
        }

        protected override void OnMouseLeave(EventArgs e)
        {
            base.OnMouseLeave(e);

            this.mousedownobject = null;
            this.mousedownpoint = Point.Empty;
            this.mouseenterobject = null;
            this.Invalidate();
        }

        protected override void OnMouseDown(MouseEventArgs e)
        {
            if (this.ReadOnly)
                return;

            if (!this.Focused)
            {
                this.Focus();
            }
            this.activatedVisible = false;

            if (e.Button == MouseButtons.Left)
            {
                // 上一年按钮
                if (this.dateBody.TopBar_prev_year_btn.Rect.Contains(e.Location))
                {
                    this.mousedownobject = this.dateBody.TopBar_prev_year_btn;
                    this.mousedownpoint = Point.Empty;
                    goto result;
                }
                // 上一月按钮
                if (this.IsContainEmbodyForCurrentFormat(DateElement.Day) && this.dateBody.TopBar_prev_month_btn.Rect.Contains(e.Location))
                {
                    this.mousedownobject = this.dateBody.TopBar_prev_month_btn;
                    this.mousedownpoint = Point.Empty;
                    goto result;
                }
                //年月按钮
                if (this.DateFormat == DatePickerFormats.yyyyMM && this.dateBody.TopBar_monthyear_btn.Rect.Contains(e.Location))
                {
                    this.mousedownobject = this.dateBody.TopBar_monthyear_btn;
                    this.mousedownpoint = Point.Empty;
                    goto result;
                }
                // 月按钮
                if (this.IsContainEmbodyForCurrentFormat(DateElement.Day) && this.dateBody.TopBar_month_btn.Rect.Contains(e.Location))
                {
                    this.mousedownobject = this.dateBody.TopBar_month_btn;
                    this.mousedownpoint = Point.Empty;
                    goto result;
                }
                // 年按钮
                if (this.IsContainEmbodyForCurrentFormat(DateElement.Month) && this.dateBody.TopBar_year_btn.Rect.Contains(e.Location))
                {
                    this.mousedownobject = this.dateBody.TopBar_year_btn;
                    this.mousedownpoint = Point.Empty;
                    goto result;
                }
                // 下一月按钮
                if (this.IsContainEmbodyForCurrentFormat(DateElement.Day) && this.dateBody.TopBar_next_month_btn.Rect.Contains(e.Location))
                {
                    this.mousedownobject = this.dateBody.TopBar_next_month_btn;
                    this.mousedownpoint = Point.Empty;
                    goto result;
                }
                // 下一年按钮
                if (this.dateBody.TopBar_next_year_btn.Rect.Contains(e.Location))
                {
                    this.mousedownobject = this.dateBody.TopBar_next_year_btn;
                    this.mousedownpoint = Point.Empty;
                    goto result;
                }

                // 年选项
                if (this.IsContainEmbodyForCurrentView(DateElement.Year) && this.dateBody.YearMain_Rect.Contains(e.Location))
                {
                    for (int i = 0; i < this.dateBody.YearMain_itemArr.Length; i++)
                    {
                        if (this.dateBody.YearMain_itemArr[i].Rect.Contains(e.Location))
                        {
                            this.mousedownobject = this.dateBody.YearMain_itemArr[i];
                            this.mousedownpoint = Point.Empty;
                            goto result;
                        }
                    }
                }
                // 月选项
                if (this.IsContainEmbodyForCurrentView(DateElement.Month) && this.dateBody.MonthMain_Rect.Contains(e.Location))
                {
                    for (int i = 0; i < this.dateBody.MonthMain_itemArr.Length; i++)
                    {
                        if (this.dateBody.MonthMain_itemArr[i].Rect.Contains(e.Location))
                        {
                            this.mousedownobject = this.dateBody.MonthMain_itemArr[i];
                            this.mousedownpoint = Point.Empty;
                            goto result;
                        }
                    }
                }
                // 日选项
                if (this.IsContainEmbodyForCurrentView(DateElement.Day) && this.dateBody.DayMain_Rect.Contains(e.Location))
                {
                    for (int i = 0; i < this.dateBody.DayMain_itemArr.Length; i++)
                    {
                        if (this.dateBody.DayMain_itemArr[i].Rect.Contains(e.Location))
                        {
                            this.mousedownobject = this.dateBody.DayMain_itemArr[i];
                            this.mousedownpoint = Point.Empty;
                            goto result;
                        }
                    }
                }
                // 时选项
                if (this.IsContainEmbodyForCurrentFormat(DateElement.Hour) && this.dateBody.TimeMain_HourArea.Rect.Contains(e.Location))
                {
                    int y = this.GetTimeItemsDisplayY(this.dateBody.TimeMain_HourArea.Scroll);
                    for (int i = 0; i < this.dateBody.TimeMain_HourArea.itemArr.Length; i++)
                    {
                        if (this.dateBody.TimeMain_HourArea.itemArr[i].Rect.Contains(new Point(e.Location.X, e.Location.Y - y)))
                        {
                            this.mousedownobject = this.dateBody.TimeMain_HourArea.itemArr[i];
                            this.mousedownpoint = Point.Empty;
                            goto result;
                        }
                    }
                }
                //时滚动条
                if (this.IsContainEmbodyForCurrentFormat(DateElement.Hour) && this.dateBody.TimeMain_HourArea.Scroll.Scroll_Slide_Rect.Contains(e.Location))
                {
                    this.mousedownobject = this.dateBody.TimeMain_HourArea.Scroll;
                    this.mousedownpoint = e.Location;
                    goto result;
                }
                //分选项
                if (this.IsContainEmbodyForCurrentFormat(DateElement.Minute) && this.dateBody.TimeMain_MinuteArea.Rect.Contains(e.Location))
                {
                    int y = this.GetTimeItemsDisplayY(this.dateBody.TimeMain_MinuteArea.Scroll);
                    for (int i = 0; i < this.dateBody.TimeMain_MinuteArea.itemArr.Length; i++)
                    {
                        if (this.dateBody.TimeMain_MinuteArea.itemArr[i].Rect.Contains(new Point(e.Location.X, e.Location.Y - y)))
                        {
                            this.mousedownobject = this.dateBody.TimeMain_MinuteArea.itemArr[i];
                            this.mousedownpoint = Point.Empty;
                            goto result;
                        }
                    }
                }
                //分滚动条
                if (this.IsContainEmbodyForCurrentFormat(DateElement.Minute) && this.dateBody.TimeMain_MinuteArea.Scroll.Scroll_Slide_Rect.Contains(e.Location))
                {
                    this.mousedownobject = this.dateBody.TimeMain_MinuteArea.Scroll;
                    this.mousedownpoint = e.Location;
                    goto result;
                }
                //秒选项
                if (this.IsContainEmbodyForCurrentFormat(DateElement.Second) && this.dateBody.TimeMain_SecondArea.Rect.Contains(e.Location))
                {
                    int y = this.GetTimeItemsDisplayY(this.dateBody.TimeMain_SecondArea.Scroll);
                    for (int i = 0; i < this.dateBody.TimeMain_SecondArea.itemArr.Length; i++)
                    {
                        if (this.dateBody.TimeMain_SecondArea.itemArr[i].Rect.Contains(new Point(e.Location.X, e.Location.Y - y)))
                        {
                            this.mousedownobject = this.dateBody.TimeMain_SecondArea.itemArr[i];
                            this.mousedownpoint = Point.Empty;
                            goto result;
                        }
                    }
                }
                //秒滚动条
                if (this.IsContainEmbodyForCurrentFormat(DateElement.Second) && this.dateBody.TimeMain_SecondArea.Scroll.Scroll_Slide_Rect.Contains(e.Location))
                {
                    this.mousedownobject = this.dateBody.TimeMain_SecondArea.Scroll;
                    this.mousedownpoint = e.Location;
                    goto result;
                }

                // 清除按钮
                if (this.dateBody.Bottombar_clear_btn.Rect.Contains(e.Location))
                {
                    this.mousedownobject = this.dateBody.Bottombar_clear_btn;
                    this.mousedownpoint = Point.Empty;
                    goto result;
                }
                // 现在按钮
                else if (this.dateBody.Bottombar_now_btn.Rect.Contains(e.Location))
                {
                    this.mousedownobject = this.dateBody.Bottombar_now_btn;
                    this.mousedownpoint = Point.Empty;
                    goto result;
                }
                // 确认按钮
                else if (this.dateBody.Bottombar_confirm_btn.Rect.Contains(e.Location))
                {
                    this.mousedownobject = this.dateBody.Bottombar_confirm_btn;
                    this.mousedownpoint = Point.Empty;
                    goto result;
                }
            }

        result:
            {

            }

            base.OnMouseDown(e);
        }

        protected override void OnMouseUp(MouseEventArgs e)
        {
            if (!this.ReadOnly)
            {
                if (e.Button == MouseButtons.Left)
                {
                    // 上一年按钮
                    if (this.dateBody.TopBar_prev_year_btn.Rect.Contains(e.Location))
                    {
                        if (this.mousedownobject == this.dateBody.TopBar_prev_year_btn)
                        {
                            this.TopBarPrevYearClick();
                        }
                        this.activatedVisible = false;
                        goto result;
                    }
                    // 上一月按钮
                    if (this.IsContainEmbodyForCurrentFormat(DateElement.Day) && this.dateBody.TopBar_prev_month_btn.Rect.Contains(e.Location))
                    {
                        if (this.mousedownobject == this.dateBody.TopBar_prev_month_btn)
                        {
                            this.TopBarPrevMonthClick();
                        }
                        this.activatedVisible = false;
                        goto result;
                    }
                    //年月按钮
                    if (this.DateFormat == DatePickerFormats.yyyyMM && this.dateBody.TopBar_monthyear_btn.Rect.Contains(e.Location))
                    {
                        if (this.mousedownobject == this.dateBody.TopBar_monthyear_btn)
                        {
                            this.TopBarYearMonthClick();
                        }
                        this.activatedVisible = false;
                        goto result;
                    }
                    // 月按钮
                    if (this.IsContainEmbodyForCurrentFormat(DateElement.Day) && this.dateBody.TopBar_month_btn.Rect.Contains(e.Location))
                    {
                        if (this.mousedownobject == this.dateBody.TopBar_month_btn)
                        {
                            this.TopBarMonthClick();
                        }
                        this.activatedVisible = false;
                        goto result;
                    }
                    // 年按钮
                    if (this.IsContainEmbodyForCurrentFormat(DateElement.Month) && this.dateBody.TopBar_year_btn.Rect.Contains(e.Location))
                    {
                        if (this.mousedownobject == this.dateBody.TopBar_year_btn)
                        {
                            this.TopBarYearClick();
                        }
                        this.activatedVisible = false;
                        goto result;
                    }
                    // 下一月按钮
                    if (this.IsContainEmbodyForCurrentFormat(DateElement.Day) && this.dateBody.TopBar_next_month_btn.Rect.Contains(e.Location))
                    {
                        if (this.mousedownobject == this.dateBody.TopBar_next_month_btn)
                        {
                            this.TopBarNextMonthClick();
                        }
                        this.activatedVisible = false;
                        goto result;
                    }
                    // 下一年按钮
                    if (this.dateBody.TopBar_next_year_btn.Rect.Contains(e.Location))
                    {
                        if (this.mousedownobject == this.dateBody.TopBar_next_year_btn)
                        {
                            this.TopBarNextYearClick();
                        }
                        this.activatedVisible = false;
                        goto result;
                    }

                    // 年选项
                    if (this.IsContainEmbodyForCurrentView(DateElement.Year) && this.dateBody.YearMain_Rect.Contains(e.Location))
                    {
                        for (int i = 0; i < this.dateBody.YearMain_itemArr.Length; i++)
                        {
                            if (this.dateBody.YearMain_itemArr[i].Rect.Contains(e.Location))
                            {
                                if (this.mousedownobject == this.dateBody.YearMain_itemArr[i] && this.dateBody.YearMain_itemArr[i].DayItemType == DayItemTypes.Normal)
                                {
                                    this.YearMainItemClick(this.dateBody.YearMain_itemArr[i]);
                                }
                                this.activatedVisible = false;
                                goto result;
                            }
                        }
                    }
                    // 月选项
                    if (this.IsContainEmbodyForCurrentView(DateElement.Month) && this.dateBody.MonthMain_Rect.Contains(e.Location))
                    {
                        for (int i = 0; i < this.dateBody.MonthMain_itemArr.Length; i++)
                        {
                            if (this.dateBody.MonthMain_itemArr[i].Rect.Contains(e.Location))
                            {
                                if (this.mousedownobject == this.dateBody.MonthMain_itemArr[i] && this.dateBody.MonthMain_itemArr[i].DayItemType == DayItemTypes.Normal)
                                {
                                    this.MonthMainItemClick(this.dateBody.MonthMain_itemArr[i]);
                                }
                                this.activatedVisible = false;
                                goto result;
                            }
                        }
                    }
                    // 日选项
                    if (this.IsContainEmbodyForCurrentView(DateElement.Day) && this.dateBody.DayMain_Rect.Contains(e.Location))
                    {
                        for (int i = 0; i < this.dateBody.DayMain_itemArr.Length; i++)
                        {
                            if (this.dateBody.DayMain_itemArr[i].Rect.Contains(e.Location))
                            {
                                if (this.mousedownobject == this.dateBody.DayMain_itemArr[i] && (this.dateBody.DayMain_itemArr[i].DayItemType == DayItemTypes.Normal || this.dateBody.DayMain_itemArr[i].DayItemType == DayItemTypes.UnCurrent))
                                {
                                    this.DayMainItemClick(this.dateBody.DayMain_itemArr[i]);
                                }
                                this.activatedVisible = false;
                                goto result;
                            }
                        }
                    }
                    // 时选项
                    if (this.IsContainEmbodyForCurrentFormat(DateElement.Hour) && this.dateBody.TimeMain_HourArea.Rect.Contains(e.Location))
                    {
                        int y = this.GetTimeItemsDisplayY(this.dateBody.TimeMain_HourArea.Scroll);
                        for (int i = 0; i < this.dateBody.TimeMain_HourArea.itemArr.Length; i++)
                        {
                            if (this.dateBody.TimeMain_HourArea.itemArr[i].Rect.Contains(new Point(e.Location.X, e.Location.Y - y)))
                            {
                                if (this.mousedownobject == this.dateBody.TimeMain_HourArea.itemArr[i])
                                {
                                    this.dateBody.selected_hour = this.dateBody.TimeMain_HourArea.itemArr[i].Value;
                                    this.Invalidate();
                                }
                                goto result;
                            }
                        }
                    }
                    //时滚动条
                    if (this.IsContainEmbodyForCurrentFormat(DateElement.Hour) && this.dateBody.TimeMain_HourArea.Scroll.Scroll_Slide_Rect.Contains(e.Location))
                    {
                        goto result;
                    }
                    //分选项
                    if (this.IsContainEmbodyForCurrentFormat(DateElement.Minute) && this.dateBody.TimeMain_MinuteArea.Rect.Contains(e.Location))
                    {
                        int y = this.GetTimeItemsDisplayY(this.dateBody.TimeMain_MinuteArea.Scroll);
                        for (int i = 0; i < this.dateBody.TimeMain_MinuteArea.itemArr.Length; i++)
                        {
                            if (this.dateBody.TimeMain_MinuteArea.itemArr[i].Rect.Contains(new Point(e.Location.X, e.Location.Y - y)))
                            {
                                if (this.mousedownobject == this.dateBody.TimeMain_MinuteArea.itemArr[i])
                                {
                                    this.dateBody.selected_minute = this.dateBody.TimeMain_MinuteArea.itemArr[i].Value;
                                    this.Invalidate();
                                }
                                goto result;
                            }
                        }
                    }
                    //分滚动条
                    if (this.IsContainEmbodyForCurrentFormat(DateElement.Minute) && this.dateBody.TimeMain_MinuteArea.Scroll.Scroll_Slide_Rect.Contains(e.Location))
                    {
                        goto result;
                    }
                    //秒选项
                    if (this.IsContainEmbodyForCurrentFormat(DateElement.Second) && this.dateBody.TimeMain_SecondArea.Rect.Contains(e.Location))
                    {
                        int y = this.GetTimeItemsDisplayY(this.dateBody.TimeMain_SecondArea.Scroll);
                        for (int i = 0; i < this.dateBody.TimeMain_SecondArea.itemArr.Length; i++)
                        {
                            if (this.dateBody.TimeMain_SecondArea.itemArr[i].Rect.Contains(new Point(e.Location.X, e.Location.Y - y)))
                            {
                                if (this.mousedownobject == this.dateBody.TimeMain_SecondArea.itemArr[i])
                                {
                                    this.dateBody.selected_second = this.dateBody.TimeMain_SecondArea.itemArr[i].Value;
                                    this.Invalidate();
                                }
                                goto result;
                            }
                        }
                    }
                    //秒滚动条
                    if (this.IsContainEmbodyForCurrentFormat(DateElement.Second) && this.dateBody.TimeMain_SecondArea.Scroll.Scroll_Slide_Rect.Contains(e.Location))
                    {
                        goto result;
                    }

                    // 清除按钮
                    if (this.dateBody.Bottombar_clear_btn.Rect.Contains(e.Location))
                    {
                        if (this.mousedownobject == this.dateBody.Bottombar_clear_btn)
                        {
                            this.OnBottomBarClearClick(new EventArgs());
                        }
                        this.activatedVisible = false;
                        goto result;
                    }
                    // 现在按钮
                    else if (this.dateBody.Bottombar_now_btn.Rect.Contains(e.Location))
                    {
                        if (this.mousedownobject == this.dateBody.Bottombar_now_btn)
                        {
                            this.OnBottomBarNowClick(new EventArgs());
                        }
                        this.activatedVisible = false;
                        goto result;
                    }
                    // 确认按钮
                    else if (this.dateBody.Bottombar_confirm_btn.Rect.Contains(e.Location))
                    {
                        if (this.mousedownobject == this.dateBody.Bottombar_confirm_btn)
                        {
                            this.OnBottomBarConfirmClick(new EventArgs());
                        }
                        this.activatedVisible = false;
                        goto result;
                    }

                }
            }
        result:
            {
                this.mousedownobject = null;
                this.mousedownpoint = Point.Empty;
            }

            base.OnMouseUp(e);
        }

        protected override void OnMouseMove(MouseEventArgs e)
        {
            base.OnMouseMove(e);

            if (this.ReadOnly)
                return;

            // 时滚动条滚动
            if (this.mousedownobject == this.dateBody.TimeMain_HourArea.Scroll)
            {
                int offset = (int)((e.Location.Y - this.mousedownpoint.Y));
                if (this.dateBody.TimeMain_HourArea.Scroll.IsResetScrollByOffset(offset))
                {
                    this.mousedownpoint = e.Location;
                    this.Invalidate();
                    return;
                }
            }
            // 分滚动条滚动
            else if (this.mousedownobject == this.dateBody.TimeMain_MinuteArea.Scroll)
            {
                int offset = (int)((e.Location.Y - this.mousedownpoint.Y));
                if (this.dateBody.TimeMain_MinuteArea.Scroll.IsResetScrollByOffset(offset))
                {
                    this.mousedownpoint = e.Location;
                    this.Invalidate();
                    return;
                }
            }
            // 秒滚动条滚动
            else if (this.mousedownobject == this.dateBody.TimeMain_SecondArea.Scroll)
            {
                int offset = (int)((e.Location.Y - this.mousedownpoint.Y));
                if (this.dateBody.TimeMain_SecondArea.Scroll.IsResetScrollByOffset(offset))
                {
                    this.mousedownpoint = e.Location;
                    this.Invalidate();
                    return;
                }
            }
            //鼠标进入元素
            else
            {
                object mouseenterobject_tmp = null;

                // 顶部工具栏
                if (this.dateBody.TopBar_Date_Rect.Contains(e.Location))
                {
                    // 上一年按钮
                    if (this.dateBody.TopBar_prev_year_btn.Rect.Contains(e.Location))
                    {
                        mouseenterobject_tmp = this.dateBody.TopBar_prev_year_btn;
                        goto result;
                    }
                    // 上一月按钮
                    if (this.IsContainEmbodyForCurrentFormat(DateElement.Day) && this.dateBody.TopBar_prev_month_btn.Rect.Contains(e.Location))
                    {
                        mouseenterobject_tmp = this.dateBody.TopBar_prev_month_btn;
                        goto result;
                    }
                    // 月按钮
                    if (this.IsContainEmbodyForCurrentFormat(DateElement.Day) && this.dateBody.TopBar_month_btn.Rect.Contains(e.Location))
                    {
                        mouseenterobject_tmp = this.dateBody.TopBar_month_btn;
                        goto result;
                    }
                    // 年按钮
                    if (this.IsContainEmbodyForCurrentFormat(DateElement.Month) && this.dateBody.TopBar_year_btn.Rect.Contains(e.Location))
                    {
                        mouseenterobject_tmp = this.dateBody.TopBar_year_btn;
                        goto result;
                    }
                    // 下一月按钮
                    if (this.IsContainEmbodyForCurrentFormat(DateElement.Day) && this.dateBody.TopBar_next_month_btn.Rect.Contains(e.Location))
                    {
                        mouseenterobject_tmp = this.dateBody.TopBar_next_month_btn;
                        goto result;
                    }
                    // 下一年按钮
                    if (this.dateBody.TopBar_next_year_btn.Rect.Contains(e.Location))
                    {
                        mouseenterobject_tmp = this.dateBody.TopBar_next_year_btn;
                        goto result;
                    }

                    goto result;
                }
                // 年选项
                if (this.IsContainEmbodyForCurrentView(DateElement.Year) && this.dateBody.YearMain_Rect.Contains(e.Location))
                {
                    for (int i = 0; i < this.dateBody.YearMain_itemArr.Length; i++)
                    {
                        if (this.dateBody.YearMain_itemArr[i].Rect.Contains(e.Location))
                        {
                            mouseenterobject_tmp = this.dateBody.YearMain_itemArr[i];
                            goto result;
                        }
                    }

                    goto result;
                }
                // 月选项
                if (this.IsContainEmbodyForCurrentView(DateElement.Month) && this.dateBody.MonthMain_Rect.Contains(e.Location))
                {
                    for (int i = 0; i < this.dateBody.MonthMain_itemArr.Length; i++)
                    {
                        if (this.dateBody.MonthMain_itemArr[i].Rect.Contains(e.Location))
                        {
                            mouseenterobject_tmp = this.dateBody.MonthMain_itemArr[i];
                            goto result;
                        }
                    }

                    goto result;
                }
                // 日选项
                if (this.IsContainEmbodyForCurrentView(DateElement.Day) && this.dateBody.DayMain_Rect.Contains(e.Location))
                {
                    for (int i = 0; i < this.dateBody.DayMain_itemArr.Length; i++)
                    {
                        if (this.dateBody.DayMain_itemArr[i].Rect.Contains(e.Location))
                        {
                            mouseenterobject_tmp = this.dateBody.DayMain_itemArr[i];
                            goto result;
                        }
                    }

                    goto result;
                }
                // 时选项
                if (this.IsContainEmbodyForCurrentFormat(DateElement.Hour) && this.dateBody.TimeMain_HourArea.Rect.Contains(e.Location))
                {
                    int y = this.GetTimeItemsDisplayY(this.dateBody.TimeMain_HourArea.Scroll);
                    for (int i = 0; i < this.dateBody.TimeMain_HourArea.itemArr.Length; i++)
                    {
                        if (this.dateBody.TimeMain_HourArea.itemArr[i].Rect.Contains(new Point(e.Location.X, e.Location.Y - y)))
                        {
                            mouseenterobject_tmp = this.dateBody.TimeMain_HourArea.itemArr[i];
                            goto result;
                        }
                    }

                    goto result;
                }
                //时滚动条背景
                if (this.IsContainEmbodyForCurrentFormat(DateElement.Hour) && this.dateBody.TimeMain_HourArea.Scroll.Scroll_Back_Rect.Contains(e.Location))
                {
                    mouseenterobject_tmp = null;
                    goto result;
                }
                //分选项
                if (this.IsContainEmbodyForCurrentFormat(DateElement.Minute) && this.dateBody.TimeMain_MinuteArea.Rect.Contains(e.Location))
                {
                    int y = this.GetTimeItemsDisplayY(this.dateBody.TimeMain_MinuteArea.Scroll);
                    for (int i = 0; i < this.dateBody.TimeMain_MinuteArea.itemArr.Length; i++)
                    {
                        if (this.dateBody.TimeMain_MinuteArea.itemArr[i].Rect.Contains(new Point(e.Location.X, e.Location.Y - y)))
                        {
                            mouseenterobject_tmp = this.dateBody.TimeMain_MinuteArea.itemArr[i];
                            goto result;
                        }
                    }

                    goto result;
                }
                //分滚动条背景
                if (this.IsContainEmbodyForCurrentFormat(DateElement.Minute) && this.dateBody.TimeMain_MinuteArea.Scroll.Scroll_Back_Rect.Contains(e.Location))
                {
                    mouseenterobject_tmp = null;
                    goto result;
                }
                //秒选项
                if (this.IsContainEmbodyForCurrentFormat(DateElement.Second) && this.dateBody.TimeMain_SecondArea.Rect.Contains(e.Location))
                {
                    int y = this.GetTimeItemsDisplayY(this.dateBody.TimeMain_SecondArea.Scroll);
                    for (int i = 0; i < this.dateBody.TimeMain_SecondArea.itemArr.Length; i++)
                    {
                        if (this.dateBody.TimeMain_SecondArea.itemArr[i].Rect.Contains(new Point(e.Location.X, e.Location.Y - y)))
                        {
                            mouseenterobject_tmp = this.dateBody.TimeMain_SecondArea.itemArr[i];
                            goto result;
                        }
                    }

                    goto result;
                }
                //秒滚动条背景
                if (this.IsContainEmbodyForCurrentFormat(DateElement.Second) && this.dateBody.TimeMain_SecondArea.Scroll.Scroll_Back_Rect.Contains(e.Location))
                {
                    mouseenterobject_tmp = null;
                    goto result;
                }
                //底部工具栏
                if (this.dateBody.BottomBar_Rect.Contains(e.Location))
                {
                    // 清除按钮
                    if (this.dateBody.Bottombar_clear_btn.Rect.Contains(e.Location))
                    {
                        mouseenterobject_tmp = this.dateBody.Bottombar_clear_btn;
                        goto result;
                    }
                    // 现在按钮
                    if (this.dateBody.Bottombar_now_btn.Rect.Contains(e.Location))
                    {
                        mouseenterobject_tmp = this.dateBody.Bottombar_now_btn;
                        goto result;
                    }
                    // 确认按钮
                    if (this.dateBody.Bottombar_confirm_btn.Rect.Contains(e.Location))
                    {
                        mouseenterobject_tmp = this.dateBody.Bottombar_confirm_btn;
                        goto result;
                    }

                    goto result;
                }

            result:
                {
                    if (this.mouseenterobject != mouseenterobject_tmp)
                    {
                        this.mouseenterobject = mouseenterobject_tmp;
                        this.Invalidate();
                    }
                }
            }

        }

        protected override void OnMouseWheel(MouseEventArgs e)
        {
            base.OnMouseWheel(e);

            if (this.ReadOnly)
                return;

            if (this.mousedownobject != null)
                return;

            // 时区域滚动
            if (this.IsContainEmbodyForCurrentFormat(DateElement.Hour) && (this.dateBody.TimeMain_HourArea.Rect.Contains(e.Location) || this.dateBody.TimeMain_HourArea.Scroll.Scroll_Back_Rect.Contains(e.Location)))
            {
                int offset = e.Delta > 1 ? -3 : 3;
                if (this.dateBody.TimeMain_HourArea.Scroll.IsResetScrollByOffset(offset))
                {
                    this.Invalidate();
                }
                goto result;
            }
            // 分区域滚动
            if (this.IsContainEmbodyForCurrentFormat(DateElement.Minute) && (this.dateBody.TimeMain_MinuteArea.Rect.Contains(e.Location) || this.dateBody.TimeMain_MinuteArea.Scroll.Scroll_Back_Rect.Contains(e.Location)))
            {
                int offset = e.Delta > 1 ? -2 : 2;
                if (this.dateBody.TimeMain_MinuteArea.Scroll.IsResetScrollByOffset(offset))
                {
                    this.Invalidate();
                }
                goto result;
            }
            // 秒区域滚动
            if (this.IsContainEmbodyForCurrentFormat(DateElement.Minute) && (this.dateBody.TimeMain_SecondArea.Rect.Contains(e.Location) || this.dateBody.TimeMain_SecondArea.Scroll.Scroll_Back_Rect.Contains(e.Location)))
            {
                int offset = e.Delta > 1 ? -2 : 2;
                if (this.dateBody.TimeMain_SecondArea.Scroll.IsResetScrollByOffset(offset))
                {
                    this.Invalidate();
                }
                goto result;
            }

        result:
            {

            }
        }

        protected override void OnKeyUp(KeyEventArgs e)
        {
            if (!this.ReadOnly)
            {
                switch (e.KeyData)
                {
                    case Keys.Left:
                    case Keys.Right:
                    case Keys.Up:
                    case Keys.Down:
                        {
                            this.ActivateIndexByKey(e.KeyData);
                            break;
                        }
                    case Keys.Enter:
                        {
                            this.ActivateIndexClick();
                            break;
                        }
                }
            }

            base.OnKeyUp(e);
        }

        protected override void SetBoundsCore(int x, int y, int width, int height, BoundsSpecified specified)
        {
            Size size = this.GetControlAutoSize();
            base.SetBoundsCore(x, y, size.Width, size.Height, specified);
            this.InitializeLayoutRectangle();
        }

        #endregion

        #region 虚方法

        /// <summary>
        /// 清除
        /// </summary>
        /// <param name="e"></param>
        protected virtual void OnBottomBarClearClick(EventArgs e)
        {
            this.dateBody.selected_year = -1;
            this.dateBody.selected_month = -1;
            this.dateBody.selected_day = -1;
            this.dateBody.selected_hour = 0;
            this.dateBody.selected_minute = 0;
            this.dateBody.selected_second = 0;
            this.DateValue = null;

            EventHandler handler = Events[EventBottomBarClearClick] as EventHandler;
            if (handler != null)
            {
                handler(this, e);
            }

            this.UpdateYearMonthDayText();
            this.Invalidate();
        }
        /// <summary>
        /// 现在
        /// </summary>
        /// <param name="e"></param>
        protected virtual void OnBottomBarNowClick(EventArgs e)
        {
            DateTime now = DateTime.Now;

            if (this.DateFormat == DatePickerFormats.yyyy)
            {
                this.dateBody.current_display_year = now.Year;
                this.dateBody.selected_year = now.Year;
                this.DateValue = new DateTime(this.dateBody.selected_year, 1, 1, 0, 0, 0);
            }
            else if (this.DateFormat == DatePickerFormats.yyyyMM)
            {
                this.dateBody.current_display_year = now.Year;
                this.dateBody.selected_year = now.Year;
                this.dateBody.selected_month = now.Month;
                this.DateValue = new DateTime(this.dateBody.selected_year, this.dateBody.selected_month, 1, 0, 0, 0);
            }
            else if (this.DateFormat == DatePickerFormats.yyyyMMdd)
            {
                this.dateBody.current_display_year = now.Year;
                this.dateBody.current_display_month = now.Month;
                this.dateBody.selected_year = now.Year;
                this.dateBody.selected_month = now.Month;
                this.dateBody.selected_day = now.Day;
                this.dateBody.selected_hour = 0;
                this.dateBody.selected_minute = 0;
                this.dateBody.selected_second = 0;
                this.DateValue = new DateTime(this.dateBody.selected_year, this.dateBody.selected_month, this.dateBody.selected_day, 0, 0, 0);
            }
            else if (this.DateFormat == DatePickerFormats.yyyyMMddHH)
            {
                this.dateBody.current_display_year = now.Year;
                this.dateBody.current_display_month = now.Month;
                this.dateBody.selected_year = now.Year;
                this.dateBody.selected_month = now.Month;
                this.dateBody.selected_day = now.Day;
                this.dateBody.selected_hour = now.Hour;
                this.dateBody.selected_minute = 0;
                this.dateBody.selected_second = 0;
                this.DateValue = new DateTime(this.dateBody.selected_year, this.dateBody.selected_month, this.dateBody.selected_day, this.dateBody.selected_hour, 0, 0);
            }
            else if (this.DateFormat == DatePickerFormats.yyyyMMddHHmm)
            {
                this.dateBody.current_display_year = now.Year;
                this.dateBody.current_display_month = now.Month;
                this.dateBody.selected_year = now.Year;
                this.dateBody.selected_month = now.Month;
                this.dateBody.selected_day = now.Day;
                this.dateBody.selected_hour = now.Hour;
                this.dateBody.selected_minute = now.Minute;
                this.dateBody.selected_second = 0;
                this.DateValue = new DateTime(this.dateBody.selected_year, this.dateBody.selected_month, this.dateBody.selected_day, this.dateBody.selected_hour, this.dateBody.selected_minute, 0);
            }
            else if (this.DateFormat == DatePickerFormats.yyyyMMddHHmmss)
            {
                this.dateBody.current_display_year = now.Year;
                this.dateBody.current_display_month = now.Month;
                this.dateBody.selected_year = now.Year;
                this.dateBody.selected_month = now.Month;
                this.dateBody.selected_day = now.Day;
                this.dateBody.selected_hour = now.Hour;
                this.dateBody.selected_minute = now.Minute;
                this.dateBody.selected_second = now.Second;
                this.DateValue = new DateTime(this.dateBody.selected_year, this.dateBody.selected_month, this.dateBody.selected_day, this.dateBody.selected_hour, this.dateBody.selected_minute, this.dateBody.selected_second);
            }

            EventHandler handler = Events[EventBottomBarNowClick] as EventHandler;
            if (handler != null)
            {
                handler(this, e);
            }

            this.UpdateTopText();
            this.UpdateYearMonthDayText();
            this.UpdateBottomText();
            this.Invalidate();
        }
        /// <summary>
        /// 确认
        /// </summary>
        /// <param name="e"></param>
        protected virtual void OnBottomBarConfirmClick(EventArgs e)
        {
            if (this.DateFormat == DatePickerFormats.yyyy)
            {
                if (this.dateBody.selected_year == -1)
                {
                    return;
                }
                this.DateValue = new DateTime(this.dateBody.selected_year, 1, 1, 0, 0, 0);
            }
            if (this.DateFormat == DatePickerFormats.yyyyMM)
            {
                if (this.dateBody.selected_month == -1)
                {
                    return;
                }
                this.DateValue = new DateTime(this.dateBody.selected_year, this.dateBody.selected_month, 1, 0, 0, 0);
            }
            else if (this.DateFormat == DatePickerFormats.yyyyMMdd)
            {
                if (this.dateBody.selected_day == -1)
                {
                    return;
                }
                this.DateValue = new DateTime(this.dateBody.selected_year, this.dateBody.selected_month, this.dateBody.selected_day, 0, 0, 0);
            }
            else if (this.DateFormat == DatePickerFormats.yyyyMMddHH)
            {
                if (this.dateBody.selected_day == -1)
                {
                    return;
                }
                this.DateValue = new DateTime(this.dateBody.selected_year, this.dateBody.selected_month, this.dateBody.selected_day, this.dateBody.selected_hour, 0, 0);
            }
            else if (this.DateFormat == DatePickerFormats.yyyyMMddHHmm)
            {
                if (this.dateBody.selected_day == -1)
                {
                    return;
                }
                this.DateValue = new DateTime(this.dateBody.selected_year, this.dateBody.selected_month, this.dateBody.selected_day, this.dateBody.selected_hour, this.dateBody.selected_minute, 0);
            }
            else if (this.DateFormat == DatePickerFormats.yyyyMMddHHmmss)
            {
                if (this.dateBody.selected_day == -1)
                {
                    return;
                }
                this.DateValue = new DateTime(this.dateBody.selected_year, this.dateBody.selected_month, this.dateBody.selected_day, this.dateBody.selected_hour, this.dateBody.selected_minute, this.dateBody.selected_second);
            }

            EventHandler handler = Events[EventBottomBarConfirmClick] as EventHandler;
            if (handler != null)
            {
                handler(this, e);
            }
        }

        /// <summary>
        /// 日期值更改
        /// </summary>
        /// <param name="e"></param>
        protected virtual void OnDateValueChanged(EventArgs e)
        {
            EventHandler handler = Events[EventDateValueChanged] as EventHandler;
            if (handler != null)
            {
                handler(this, e);
            }
        }

        /// <summary>
        /// 日期显示格式更改
        /// </summary>
        /// <param name="e"></param>
        protected virtual void OnDateFormatChanged(EventArgs e)
        {
            EventHandler handler = Events[EventDateFormatChanged] as EventHandler;
            if (handler != null)
            {
                handler(this, e);
            }
        }

        #endregion

        #region 公开方法

        /// <summary>
        /// 根据DateValue初始化画面并刷新画面
        /// </summary>
        [EditorBrowsable(EditorBrowsableState.Advanced)]
        public void InitializeViewForDateValue()
        {
            if (this.dateValue.HasValue)
            {
                if (this.DateFormat == DatePickerFormats.yyyy || this.DateFormat == DatePickerFormats.yyyyMM)
                {
                    if (this.dateBody.current_display_year == -1)
                    {
                        this.dateBody.current_display_year = this.dateValue.Value.Year;
                    }
                    this.dateBody.current_display_month = -1;
                }
                else
                {
                    this.dateBody.current_display_year = this.dateValue.Value.Year;
                    this.dateBody.current_display_month = this.dateValue.Value.Month;
                }

                this.dateBody.selected_year = this.dateValue.Value.Year;
                this.dateBody.selected_month = this.dateValue.Value.Month;
                this.dateBody.selected_day = this.dateValue.Value.Day;
                this.dateBody.selected_hour = this.dateValue.Value.Hour;
                this.dateBody.selected_minute = this.dateValue.Value.Minute;
                this.dateBody.selected_second = this.dateValue.Value.Second;
            }
            else
            {
                DateTime now = DateTime.Now;
                if (this.DateFormat == DatePickerFormats.yyyy || this.DateFormat == DatePickerFormats.yyyyMM)
                {
                    if (this.dateBody.current_display_year == -1)
                    {
                        this.dateBody.current_display_year = now.Year;
                    }
                    this.dateBody.current_display_month = -1;
                }
                else
                {
                    this.dateBody.current_display_year = now.Year;
                    this.dateBody.current_display_month = now.Month;
                }

                if (this.DateFormat == DatePickerFormats.yyyy)
                {
                    this.dateBody.selected_year = -1;
                    this.dateBody.selected_month = -1;
                    this.dateBody.selected_day = -1;
                    this.dateBody.selected_hour = 0;
                    this.dateBody.selected_minute = 0;
                    this.dateBody.selected_second = 0;
                }
                else if (this.DateFormat == DatePickerFormats.yyyyMM)
                {
                    this.dateBody.selected_year = now.Year;
                    this.dateBody.selected_month = -1;
                    this.dateBody.selected_day = -1;
                    this.dateBody.selected_hour = 0;
                    this.dateBody.selected_minute = 0;
                    this.dateBody.selected_second = 0;
                }
                else if (this.DateFormat == DatePickerFormats.yyyyMMdd || this.DateFormat == DatePickerFormats.yyyyMMddHH || this.DateFormat == DatePickerFormats.yyyyMMddHHmm || this.DateFormat == DatePickerFormats.yyyyMMddHHmmss)
                {
                    this.dateBody.selected_year = now.Year;
                    this.dateBody.selected_month = now.Month;
                    this.dateBody.selected_day = -1;
                    this.dateBody.selected_hour = 0;
                    this.dateBody.selected_minute = 0;
                    this.dateBody.selected_second = 0;
                }
            }

            if (this.DateFormat == DatePickerFormats.yyyy)
            {
                this.SetCurrentDateFormatsViews(DateFormatsViews.Year_Year);
            }
            else if (this.DateFormat == DatePickerFormats.yyyyMM)
            {
                this.SetCurrentDateFormatsViews(DateFormatsViews.YearMonth_Month);
            }
            else
            {
                this.SetCurrentDateFormatsViews(DateFormatsViews.YearMonthDay_Day);
            }

            this.UpdateTopText();
            this.UpdateYearMonthDayText();
            this.UpdateBottomText();
            this.AutoMiddleSelectedTimeItem();
            this.Invalidate();
        }

        /// <summary>
        /// 设置日期值（但不会触发 DateValueChanged 事件）
        /// </summary>
        /// <param name="value">日期</param>
        public void UpdateDateValue(DateTime? value)
        {
            if (this.dateValue == value)
                return;

            if (value.HasValue && (this.MinValue > value.Value.Date || value.Value.Date > this.MaxValue))
            {
                throw new ArgumentOutOfRangeException("“value”应介于 'MinDate' 和 'MaxDate' 之间");
            }

            this.dateValue = value;

            this.InitializeViewForDateValue();
        }

        #endregion

        #region 私有方法

        /// <summary>
        /// 初始化控件布局
        /// </summary>
        private void InitializeLayoutRectangle()
        {
            IntPtr hDC;
            Graphics g;
            ControlHelper.GetWindowClientGraphics(this.Handle, out g, out hDC);

            int scale_topbar_rect_height = (int)(this.topbar_rect_height * this.ScaleDpi);

            int scale_year_rectf_item_width = (int)(this.year_item_rect_width * this.ScaleDpi);
            int scale_year_rectf_item_height = (int)(this.year_item_rect_height * this.ScaleDpi);
            int scale_month_rectf_item_width = (int)(this.month_item_rect_width * this.ScaleDpi);
            int scale_month_rectf_item_height = (int)(this.month_item_rect_height * this.ScaleDpi);
            int scale_date_rect_width = (int)(this.mainbar_rect_width * this.ScaleDpi);
            int scale_date_rect_height = (int)(this.mainbar_rect_height * this.ScaleDpi);
            int scale_day_rectf_item_width = (int)(this.day_item_rect_width * this.ScaleDpi);
            int scale_day_rectf_item_height = (int)(this.day_item_rect_height * this.ScaleDpi);
            int scale_time_rect_width = (int)(this.time_item_rect_width * this.ScaleDpi);
            int scale_time_scroll_thickness = (int)(this.time_scroll_thickness * this.ScaleDpi);

            int scale_bottombar_rect_height = (int)(this.bottombar_rect_height * this.ScaleDpi);

            this.dateBody.TopBar_Rect = new Rectangle(this.ClientRectangle.X, this.ClientRectangle.Y, this.ClientRectangle.Width, scale_topbar_rect_height);
            this.dateBody.TopBar_Date_Rect = new Rectangle(this.ClientRectangle.X, this.ClientRectangle.Y, scale_date_rect_width, scale_topbar_rect_height);
            this.dateBody.TopBar_Time_Rect = new Rectangle(scale_date_rect_width, this.ClientRectangle.Y, this.ClientRectangle.Width - scale_date_rect_width, scale_topbar_rect_height);
            this.dateBody.MainBar_Rect = new Rectangle(this.ClientRectangle.X, this.ClientRectangle.Y + scale_topbar_rect_height, this.ClientRectangle.Width, scale_date_rect_height);
            this.dateBody.YearMain_Rect = new Rectangle(this.dateBody.MainBar_Rect.X, this.dateBody.MainBar_Rect.Y, scale_date_rect_width, scale_date_rect_height);
            this.dateBody.MonthMain_Rect = this.dateBody.YearMain_Rect;
            this.dateBody.DayMain_Rect = this.dateBody.YearMain_Rect;
            this.dateBody.TimeMain_Rect = new Rectangle(this.ClientRectangle.X + scale_date_rect_width + date_time_rect_space, this.ClientRectangle.Y + scale_topbar_rect_height, scale_date_rect_width, this.ClientRectangle.Height - scale_topbar_rect_height - scale_bottombar_rect_height);
            this.dateBody.BottomBar_Rect = new Rectangle(this.ClientRectangle.X, this.ClientRectangle.Bottom - scale_bottombar_rect_height, this.ClientRectangle.Width, scale_bottombar_rect_height);

            #region 顶部工具栏
            int topbar_btn_rectf_width = (int)(24 * this.ScaleDpi);
            float topbar_avg_w = topbar_btn_rectf_width / 3f;
            float topbar_avg_h = this.dateBody.TopBar_Date_Rect.Height / 6f;
            int scale_line_interval = (int)(3 * this.ScaleDpi);

            #region 上一年
            this.dateBody.TopBar_prev_year_btn.Rect = new Rectangle(this.dateBody.TopBar_Date_Rect.X, this.dateBody.TopBar_Date_Rect.Y, topbar_btn_rectf_width, this.dateBody.TopBar_Date_Rect.Height);
            this.dateBody.TopBar_prev_year_btn.LineLeftPointArr = new Point[3];
            this.dateBody.TopBar_prev_year_btn.LineLeftPointArr[0] = new Point((int)(this.dateBody.TopBar_prev_year_btn.Rect.X + topbar_avg_w * 2 - scale_line_interval), (int)(this.dateBody.TopBar_prev_year_btn.Rect.Y + topbar_avg_h * 2));
            this.dateBody.TopBar_prev_year_btn.LineLeftPointArr[1] = new Point((int)(this.dateBody.TopBar_prev_year_btn.Rect.X + topbar_avg_w), (int)(this.dateBody.TopBar_prev_year_btn.Rect.Y + topbar_avg_h * 3));
            this.dateBody.TopBar_prev_year_btn.LineLeftPointArr[2] = new Point((int)(this.dateBody.TopBar_prev_year_btn.Rect.X + topbar_avg_w * 2 - scale_line_interval), (int)(this.dateBody.TopBar_prev_year_btn.Rect.Y + topbar_avg_h * 4));

            this.dateBody.TopBar_prev_year_btn.LineRightPointArr = new Point[3];
            this.dateBody.TopBar_prev_year_btn.LineRightPointArr[0] = new Point((int)(this.dateBody.TopBar_prev_year_btn.Rect.X + topbar_avg_w * 2), (int)(this.dateBody.TopBar_prev_year_btn.Rect.Y + topbar_avg_h * 2));
            this.dateBody.TopBar_prev_year_btn.LineRightPointArr[1] = new Point((int)(this.dateBody.TopBar_prev_year_btn.Rect.X + topbar_avg_w + scale_line_interval), (int)(this.dateBody.TopBar_prev_year_btn.Rect.Y + topbar_avg_h * 3));
            this.dateBody.TopBar_prev_year_btn.LineRightPointArr[2] = new Point((int)(this.dateBody.TopBar_prev_year_btn.Rect.X + topbar_avg_w * 2), (int)(this.dateBody.TopBar_prev_year_btn.Rect.Y + topbar_avg_h * 4));
            #endregion
            #region 上一月
            this.dateBody.TopBar_prev_month_btn.Rect = new Rectangle(this.dateBody.TopBar_Date_Rect.X + topbar_btn_rectf_width, this.dateBody.TopBar_Date_Rect.Y, topbar_btn_rectf_width, this.dateBody.TopBar_Date_Rect.Height);

            this.dateBody.TopBar_prev_month_btn.LineLeftPointArr = new Point[3];
            this.dateBody.TopBar_prev_month_btn.LineLeftPointArr[0] = new Point((int)(this.dateBody.TopBar_prev_month_btn.Rect.X + topbar_avg_w * 2 - 3), (int)(this.dateBody.TopBar_prev_month_btn.Rect.Y + topbar_avg_h * 2));
            this.dateBody.TopBar_prev_month_btn.LineLeftPointArr[1] = new Point((int)(this.dateBody.TopBar_prev_month_btn.Rect.X + topbar_avg_w), (int)(this.dateBody.TopBar_prev_month_btn.Rect.Y + topbar_avg_h * 3));
            this.dateBody.TopBar_prev_month_btn.LineLeftPointArr[2] = new Point((int)(this.dateBody.TopBar_prev_month_btn.Rect.X + topbar_avg_w * 2 - 3), (int)(this.dateBody.TopBar_prev_month_btn.Rect.Y + topbar_avg_h * 4));
            #endregion

            int scale_yearscope_btn_width = (int)(120 * this.ScaleDpi);
            int scale_monthyear_btn_width = (int)(60 * this.ScaleDpi);
            int scale_month_btn_width = (int)(37 * this.ScaleDpi);
            this.dateBody.TopBar_yearscope_btn.Rect = new Rectangle(this.dateBody.TopBar_Date_Rect.X + (this.dateBody.TopBar_Date_Rect.Width - scale_yearscope_btn_width) / 2, this.dateBody.TopBar_Date_Rect.Y, scale_yearscope_btn_width, this.dateBody.TopBar_Date_Rect.Height);
            this.dateBody.TopBar_monthyear_btn.Rect = new Rectangle(this.dateBody.TopBar_Date_Rect.X + (this.dateBody.TopBar_Date_Rect.Width - scale_monthyear_btn_width) / 2, this.dateBody.TopBar_Date_Rect.Y, scale_monthyear_btn_width, this.dateBody.TopBar_Date_Rect.Height);
            this.dateBody.TopBar_month_btn.Rect = new Rectangle(this.dateBody.TopBar_Date_Rect.X + (this.dateBody.TopBar_Date_Rect.Width - (scale_month_btn_width + scale_monthyear_btn_width)) / 2, this.dateBody.TopBar_Date_Rect.Y, scale_month_btn_width, this.dateBody.TopBar_Date_Rect.Height);
            this.dateBody.TopBar_year_btn.Rect = new Rectangle(this.dateBody.TopBar_Date_Rect.X + (this.dateBody.TopBar_Date_Rect.Width - (scale_month_btn_width + scale_monthyear_btn_width)) / 2 + scale_month_btn_width, this.dateBody.TopBar_Date_Rect.Y, scale_monthyear_btn_width, this.dateBody.TopBar_Date_Rect.Height);
            #region 下一月
            this.dateBody.TopBar_next_month_btn.Rect = new Rectangle(this.dateBody.TopBar_Date_Rect.Right - topbar_btn_rectf_width - topbar_btn_rectf_width, this.dateBody.TopBar_Date_Rect.Y, topbar_btn_rectf_width, this.dateBody.TopBar_Date_Rect.Height);

            this.dateBody.TopBar_next_month_btn.LineRightPointArr = new Point[3];
            this.dateBody.TopBar_next_month_btn.LineRightPointArr[0] = new Point((int)(this.dateBody.TopBar_next_month_btn.Rect.Right - topbar_avg_w * 2 + 3), (int)(this.dateBody.TopBar_next_month_btn.Rect.Y + topbar_avg_h * 2));
            this.dateBody.TopBar_next_month_btn.LineRightPointArr[1] = new Point((int)(this.dateBody.TopBar_next_month_btn.Rect.Right - topbar_avg_w), (int)(this.dateBody.TopBar_next_month_btn.Rect.Y + topbar_avg_h * 3));
            this.dateBody.TopBar_next_month_btn.LineRightPointArr[2] = new Point((int)(this.dateBody.TopBar_next_month_btn.Rect.Right - topbar_avg_w * 2 + 3), (int)(this.dateBody.TopBar_next_month_btn.Rect.Y + topbar_avg_h * 4));
            #endregion
            #region 下一年
            this.dateBody.TopBar_next_year_btn.Rect = new Rectangle(this.dateBody.TopBar_Date_Rect.Right - topbar_btn_rectf_width, this.dateBody.TopBar_Date_Rect.Y, topbar_btn_rectf_width, this.dateBody.TopBar_Date_Rect.Height);

            this.dateBody.TopBar_next_year_btn.LineLeftPointArr = new Point[3];
            this.dateBody.TopBar_next_year_btn.LineLeftPointArr[0] = new Point((int)(this.dateBody.TopBar_next_year_btn.Rect.Right - topbar_avg_w * 2 + scale_line_interval), (int)(this.dateBody.TopBar_next_year_btn.Rect.Y + topbar_avg_h * 2));
            this.dateBody.TopBar_next_year_btn.LineLeftPointArr[1] = new Point((int)(this.dateBody.TopBar_next_year_btn.Rect.Right - topbar_avg_w), (int)(this.dateBody.TopBar_next_year_btn.Rect.Y + topbar_avg_h * 3));
            this.dateBody.TopBar_next_year_btn.LineLeftPointArr[2] = new Point((int)(this.dateBody.TopBar_next_year_btn.Rect.Right - topbar_avg_w * 2 + scale_line_interval), (int)(this.dateBody.TopBar_next_year_btn.Rect.Y + topbar_avg_h * 4));

            this.dateBody.TopBar_next_year_btn.LineRightPointArr = new Point[3];
            this.dateBody.TopBar_next_year_btn.LineRightPointArr[0] = new Point((int)(this.dateBody.TopBar_next_year_btn.Rect.Right - topbar_avg_w * 2), (int)(this.dateBody.TopBar_next_year_btn.Rect.Y + topbar_avg_h * 2));
            this.dateBody.TopBar_next_year_btn.LineRightPointArr[1] = new Point((int)(this.dateBody.TopBar_next_year_btn.Rect.Right - topbar_avg_w - scale_line_interval), (int)(this.dateBody.TopBar_next_year_btn.Rect.Y + topbar_avg_h * 3));
            this.dateBody.TopBar_next_year_btn.LineRightPointArr[2] = new Point((int)(this.dateBody.TopBar_next_year_btn.Rect.Right - topbar_avg_w * 2), (int)(this.dateBody.TopBar_next_year_btn.Rect.Y + topbar_avg_h * 4));
            #endregion
            this.dateBody.TopBar_hour_rect = new Rectangle(this.dateBody.TimeMain_Rect.X + date_time_rect_space, this.dateBody.TopBar_Date_Rect.Y, scale_time_rect_width, this.dateBody.TopBar_Date_Rect.Height);
            this.dateBody.TopBar_minute_rect = new Rectangle(this.dateBody.TopBar_hour_rect.Right + scale_time_scroll_thickness, this.dateBody.TopBar_Date_Rect.Y, scale_time_rect_width, this.dateBody.TopBar_Date_Rect.Height);
            this.dateBody.TopBar_second_rect = new Rectangle(this.dateBody.TopBar_minute_rect.Right + scale_time_scroll_thickness, this.dateBody.TopBar_Date_Rect.Y, scale_time_rect_width, this.dateBody.TopBar_Date_Rect.Height);
            #endregion
            #region 年面板
            int year_col = 3;
            int year_row = 4;
            float year_space_width = (scale_date_rect_width - scale_year_rectf_item_width * year_col) / (float)(year_col + 1);
            float year_space_height = (scale_date_rect_height - scale_year_rectf_item_height * year_row) / (float)(year_row + 1);
            for (int i = 0; i < this.dateBody.YearMain_itemArr.Length; i++)
            {
                float x = this.dateBody.YearMain_Rect.X + year_space_width + (i % year_col) * (scale_year_rectf_item_width + year_space_width);
                float y = this.dateBody.YearMain_Rect.Y + year_space_height + (i / year_col) * (scale_year_rectf_item_height + year_space_height);
                this.dateBody.YearMain_itemArr[i].Rect = new Rectangle((int)x, (int)y, scale_year_rectf_item_width, scale_year_rectf_item_height);
            }
            #endregion
            #region 月面板
            int month_col = 3;
            int month_row = 4;
            float month_space_width = (scale_date_rect_width - scale_month_rectf_item_width * month_col) / (float)(month_col + 1);
            float month_space_height = (scale_date_rect_height - scale_month_rectf_item_height * month_row) / (float)(month_row + 1);
            for (int i = 0; i < this.dateBody.MonthMain_itemArr.Length; i++)
            {
                float x = this.dateBody.MonthMain_Rect.X + month_space_width + (i % month_col) * (scale_month_rectf_item_width + month_space_width);
                float y = this.dateBody.MonthMain_Rect.Y + month_space_height + (i / month_col) * (scale_month_rectf_item_height + month_space_height);
                this.dateBody.MonthMain_itemArr[i].Rect = new Rectangle((int)x, (int)y, scale_month_rectf_item_width, scale_month_rectf_item_height);
            }
            #endregion
            #region 日面板

            int day_col = 7;
            int day_row = 7;

            float day_space_width = 1;
            float day_space_height = 1;
            float day_space_left = (scale_date_rect_width - scale_day_rectf_item_width * day_col - day_space_width * (day_col - 1)) / 2f;
            float day_space_top = (scale_date_rect_height - scale_day_rectf_item_height * day_row - day_space_height * (day_row - 1)) / 2f;

            //标题
            for (int i = 0; i < this.dateBody.DayMain_titleArr.Length; i++)
            {
                float x = this.dateBody.DayMain_Rect.X + day_space_left + (i % day_col) * (scale_day_rectf_item_width + day_space_width);
                float y = this.dateBody.DayMain_Rect.Y + day_space_top;
                this.dateBody.DayMain_titleArr[i].Rect = new Rectangle((int)x, (int)y, scale_day_rectf_item_width, scale_day_rectf_item_height);
            }

            for (int i = 0; i < this.dateBody.DayMain_itemArr.Length; i++)
            {
                float x = this.dateBody.DayMain_Rect.X + day_space_left + (i % day_col) * (scale_day_rectf_item_width + day_space_width);
                float y = this.dateBody.DayMain_Rect.Y + scale_day_rectf_item_height + day_space_top + (i / day_col) * (scale_day_rectf_item_height + day_space_height);
                this.dateBody.DayMain_itemArr[i].Rect = new Rectangle((int)x, (int)y, scale_day_rectf_item_width, scale_day_rectf_item_height);
            }

            #endregion
            #region 时间面板
            int scale_time_item_height = (int)(this.time_item_rect_height * this.ScaleDpi);
            int scale_timeScrollThickness = (int)(this.time_scroll_thickness * this.ScaleDpi);
            int scale_item_w = (int)(this.time_item_rect_width * this.ScaleDpi);

            #region 选项信息
            int item_y = this.dateBody.TimeMain_Rect.Y;

            #endregion

            #region 时分秒区域
            this.dateBody.TimeMain_HourArea.Rect = new RectangleF(this.dateBody.TimeMain_Rect.X, this.dateBody.TimeMain_Rect.Y, scale_item_w, this.dateBody.TimeMain_Rect.Height);
            this.dateBody.TimeMain_MinuteArea.Rect = new RectangleF(this.dateBody.TimeMain_Rect.X + scale_item_w + scale_timeScrollThickness, this.dateBody.TimeMain_Rect.Y, scale_item_w, this.dateBody.TimeMain_Rect.Height);
            this.dateBody.TimeMain_SecondArea.Rect = new RectangleF(this.dateBody.TimeMain_Rect.X + scale_item_w * 2f + scale_timeScrollThickness * 2, this.dateBody.TimeMain_Rect.Y, scale_item_w, this.dateBody.TimeMain_Rect.Height);
            #endregion

            #region 时分秒选项
            for (int i = 0; i < this.dateBody.TimeMain_HourArea.itemArr.Length; i++)
            {
                this.dateBody.TimeMain_HourArea.itemArr[i].Rect = new Rectangle((int)this.dateBody.TimeMain_HourArea.Rect.X, item_y, scale_item_w, scale_time_item_height);
                item_y += scale_time_item_height;
            }
            item_y = this.dateBody.TimeMain_Rect.Y;
            for (int i = 0; i < this.dateBody.TimeMain_MinuteArea.itemArr.Length; i++)
            {
                this.dateBody.TimeMain_MinuteArea.itemArr[i].Rect = new Rectangle((int)this.dateBody.TimeMain_MinuteArea.Rect.X, item_y, scale_item_w, scale_time_item_height);
                item_y += scale_time_item_height;
            }
            item_y = this.dateBody.TimeMain_Rect.Y;
            for (int i = 0; i < this.dateBody.TimeMain_SecondArea.itemArr.Length; i++)
            {
                this.dateBody.TimeMain_SecondArea.itemArr[i].Rect = new Rectangle((int)this.dateBody.TimeMain_SecondArea.Rect.X, item_y, scale_item_w, scale_time_item_height);
                item_y += scale_time_item_height;
            }
            #endregion

            #region 时分秒滚动条
            this.InitializeTimeScrollLayoutRectangle(this.dateBody.TimeMain_HourArea.Scroll, this.dateBody.TimeMain_HourArea.Rect, this.dateBody.TimeMain_HourArea.itemArr.Length, scale_time_item_height);
            this.InitializeTimeScrollLayoutRectangle(this.dateBody.TimeMain_MinuteArea.Scroll, this.dateBody.TimeMain_MinuteArea.Rect, this.dateBody.TimeMain_MinuteArea.itemArr.Length, scale_time_item_height);
            this.InitializeTimeScrollLayoutRectangle(this.dateBody.TimeMain_SecondArea.Scroll, this.dateBody.TimeMain_SecondArea.Rect, this.dateBody.TimeMain_SecondArea.itemArr.Length, scale_time_item_height);
            #endregion
            #endregion
            #region 底部工具栏
            int bottombar_btn_rectf_width = (int)(36 * this.ScaleDpi);
            int bottombar_btn_rectf_height = (int)(28 * this.ScaleDpi);
            int bottombar_space_width = (int)(2 * this.ScaleDpi);
            int bottombar_space_right = (int)(3 * this.ScaleDpi);
            int bottombar_time_width = (int)(26 * this.ScaleDpi);
            int bottombar_btn_y = this.dateBody.BottomBar_Rect.Y + (this.dateBody.BottomBar_Rect.Height - bottombar_btn_rectf_height) / 2;

            int bottombar_tip_left_padding = (int)(5 * this.ScaleDpi);
            int bottombar_tip_topbottom_padding = (int)(10 * this.ScaleDpi);
            int bottombar_tip_border_width = (int)(6 * this.ScaleDpi);
            this.dateBody.Bottombar_minmaxborder_lab.LinePointArr = new Point[4];
            this.dateBody.Bottombar_minmaxborder_lab.LinePointArr[0] = new Point(this.dateBody.BottomBar_Rect.X + bottombar_tip_left_padding + bottombar_tip_border_width, this.dateBody.BottomBar_Rect.Y + bottombar_tip_topbottom_padding);
            this.dateBody.Bottombar_minmaxborder_lab.LinePointArr[1] = new Point(this.dateBody.BottomBar_Rect.X + bottombar_tip_left_padding, this.dateBody.BottomBar_Rect.Y + bottombar_tip_topbottom_padding);
            this.dateBody.Bottombar_minmaxborder_lab.LinePointArr[2] = new Point(this.dateBody.BottomBar_Rect.X + bottombar_tip_left_padding, this.dateBody.BottomBar_Rect.Bottom - bottombar_tip_topbottom_padding);
            this.dateBody.Bottombar_minmaxborder_lab.LinePointArr[3] = new Point(this.dateBody.BottomBar_Rect.X + bottombar_tip_left_padding + bottombar_tip_border_width, this.dateBody.BottomBar_Rect.Bottom - bottombar_tip_topbottom_padding);

            Size bottombar_mindate_lab_size = g.MeasureString("9999-01-01", this.Font, int.MaxValue, StringFormat.GenericTypographic).ToSize();
            this.dateBody.Bottombar_mindate_lab.Rect = new Rectangle(this.dateBody.BottomBar_Rect.X + bottombar_tip_left_padding + bottombar_tip_border_width * 2, this.dateBody.BottomBar_Rect.Top + bottombar_tip_topbottom_padding - bottombar_mindate_lab_size.Height / 2, bottombar_mindate_lab_size.Width, bottombar_mindate_lab_size.Height);
            Size bottombar_maxdate_lab_size = g.MeasureString("9999-01-01", this.Font, int.MaxValue, StringFormat.GenericTypographic).ToSize();
            this.dateBody.Bottombar_maxdate_lab.Rect = new Rectangle(this.dateBody.BottomBar_Rect.X + bottombar_tip_left_padding + bottombar_tip_border_width * 2, this.dateBody.BottomBar_Rect.Bottom - bottombar_tip_topbottom_padding - bottombar_maxdate_lab_size.Height / 2, bottombar_maxdate_lab_size.Width, bottombar_maxdate_lab_size.Height);

            this.dateBody.Bottombar_confirm_btn.Rect = new Rectangle(this.dateBody.BottomBar_Rect.Right - bottombar_space_right - bottombar_btn_rectf_width, bottombar_btn_y, bottombar_btn_rectf_width, bottombar_btn_rectf_height);
            this.dateBody.Bottombar_now_btn.Rect = new Rectangle(this.dateBody.Bottombar_confirm_btn.Rect.X - bottombar_space_width - bottombar_btn_rectf_width, bottombar_btn_y, bottombar_btn_rectf_width, bottombar_btn_rectf_height);
            this.dateBody.Bottombar_clear_btn.Rect = new Rectangle(this.dateBody.Bottombar_now_btn.Rect.X - bottombar_space_width - bottombar_btn_rectf_width, bottombar_btn_y, bottombar_btn_rectf_width, bottombar_btn_rectf_height);

            #endregion

            g.Dispose();
            NativeMethods.ReleaseDC(this.Handle, hDC);
        }

        /// <summary>
        /// 初始化时间滚动条布局
        /// </summary>
        /// <param name="scroll_obj">时间滚动条对象</param>
        /// <param name="display_rect">时间选项显示区域</param>
        /// <param name="item_count">时间选项总数</param>
        /// <param name="item_height">时间选项高度</param>
        private void InitializeTimeScrollLayoutRectangle(TimeAreaScrollClass scroll_obj, RectangleF display_rect, int item_count, int item_height)
        {
            int scale_timeScrollThickness = (int)(this.time_scroll_thickness * this.ScaleDpi);

            scroll_obj.Owner_Display_Rect = new RectangleF(display_rect.X, display_rect.Y, display_rect.Width, display_rect.Height);
            scroll_obj.Owner_Content_Rect = new RectangleF(display_rect.X, display_rect.Y, display_rect.Width, item_count * item_height);

            scroll_obj.Scroll_Back_Rect = new RectangleF(display_rect.Right, display_rect.Y, scale_timeScrollThickness, display_rect.Height);
            float slide_h = scroll_obj.Owner_Display_Rect.Height * scroll_obj.Scroll_Back_Rect.Height / scroll_obj.Owner_Content_Rect.Height;
            if (scroll_obj.Owner_Content_Rect.Height <= scroll_obj.Owner_Display_Rect.Height)
            {
                slide_h = scroll_obj.Scroll_Back_Rect.Height;
            }
            scroll_obj.Scroll_Slide_Rect = new RectangleF(scroll_obj.Scroll_Back_Rect.X, scroll_obj.Scroll_Back_Rect.Y, scale_timeScrollThickness, slide_h);
        }

        /// <summary>
        /// 更新顶部画面文本信息
        /// </summary>
        private void UpdateTopText()
        {
            if (this.DateFormat == DatePickerFormats.yyyy)
            {
                int start_year = GetStartYaer(this.dateBody.current_display_year);
                this.dateBody.TopBar_yearscope_btn.Text = String.Format("{0}年~{1}年", start_year.ToString().PadLeft(4, '0'), (start_year + 11).ToString().PadLeft(4, '0'));
                this.dateBody.TopBar_monthyear_btn.Text = "";
                this.dateBody.TopBar_month_btn.Text = "";
                this.dateBody.TopBar_year_btn.Text = "";
            }
            else if (this.DateFormat == DatePickerFormats.yyyyMM)
            {

                this.dateBody.TopBar_yearscope_btn.Text = "";
                this.dateBody.TopBar_monthyear_btn.Text = this.dateBody.current_display_year + "年";
                this.dateBody.TopBar_month_btn.Text = "";
                this.dateBody.TopBar_year_btn.Text = "";
            }
            else
            {
                this.dateBody.TopBar_yearscope_btn.Text = "";
                this.dateBody.TopBar_monthyear_btn.Text = "";
                this.dateBody.TopBar_month_btn.Text = String.Format("{0}月", this.dateBody.current_display_month.ToString().PadLeft(2, '0'));
                this.dateBody.TopBar_year_btn.Text = String.Format("{0}年", this.dateBody.current_display_year.ToString().PadLeft(4, '0'));
            }
        }

        /// <summary>
        /// 更新年月日画面文本信息 
        /// </summary>
        private void UpdateYearMonthDayText()
        {
            // 年面板
            if (this.IsContainEmbodyForCurrentFormat(DateElement.Year))
            {
                int start_year = GetStartYaer(this.dateBody.current_display_year);
                for (int i = 0; i < this.dateBody.YearMain_itemArr.Length; i++)
                {
                    int year = start_year + i;
                    this.dateBody.YearMain_itemArr[i].Value = "10" + (start_year + i).ToString().PadLeft(4, '0');
                    this.dateBody.YearMain_itemArr[i].DayItemType = (year < this.MinValue.Year || year > this.MaxValue.Year) ? DayItemTypes.Disabled : DayItemTypes.Normal;
                }
            }
            // 月面板
            if (this.IsContainEmbodyForCurrentFormat(DateElement.Month))
            {
                int ym_min_month = int.Parse(this.MinValue.ToString("10yyyyMM"));
                int ym_max_month = int.Parse(this.MaxValue.ToString("10yyyyMM"));
                for (int i = 0; i < this.dateBody.MonthMain_itemArr.Length; i++)
                {
                    int ym_now_month = int.Parse("10" + this.dateBody.current_display_year.ToString().PadLeft(4, '0') + (i + 1).ToString().PadLeft(2, '0'));
                    this.dateBody.MonthMain_itemArr[i].Value = ym_now_month.ToString();
                    this.dateBody.MonthMain_itemArr[i].DayItemType = (ym_min_month > ym_now_month || ym_now_month > ym_max_month) ? DayItemTypes.Disabled : DayItemTypes.Normal;
                }
            }
            // 日面板
            if (this.IsContainEmbodyForCurrentFormat(DateElement.Day))
            {
                int days = DateTime.DaysInMonth(this.dateBody.current_display_year, this.dateBody.current_display_month);//指定月份的总天数
                DateTime first_day = new DateTime(this.dateBody.current_display_year, this.dateBody.current_display_month, 1, 0, 0, 0);//指定年月的第一天
                int first_day_weekday = (int)(first_day.DayOfWeek);//指定日期为星期几
                if (first_day_weekday == 0)
                {
                    first_day_weekday = 7;
                }

                DateTime ymd_min = this.MinValue.Date;
                DateTime ymd_max = this.MaxValue.Date;
                for (int i = 0; i < this.dateBody.DayMain_itemArr.Length; i++)
                {
                    if (i < first_day_weekday)//绘制指定月份上一个月的日期
                    {
                        int day = -(first_day_weekday - i);
                        DateTime ymd_now = first_day.AddDays(day);
                        this.dateBody.DayMain_itemArr[i].Value = ymd_now.ToString("10yyyyMMdd");
                        this.dateBody.DayMain_itemArr[i].DayItemType = (ymd_min > ymd_now || ymd_now > ymd_max) ? DayItemTypes.Disabled : DayItemTypes.UnCurrent;
                    }
                    else if (i - first_day_weekday < days)//绘制指定月份的日期
                    {
                        int day = i - first_day_weekday;
                        DateTime ymd_now = first_day.AddDays(day).Date;
                        this.dateBody.DayMain_itemArr[i].Value = ymd_now.ToString("10yyyyMMdd");
                        this.dateBody.DayMain_itemArr[i].DayItemType = (ymd_min > ymd_now || ymd_now > ymd_max) ? DayItemTypes.Disabled : DayItemTypes.Normal;
                    }
                    else//绘制指定月份下一个月的日期
                    {
                        int day = i - first_day_weekday;
                        DateTime ymd_now = first_day.AddDays(day).Date;
                        this.dateBody.DayMain_itemArr[i].Value = ymd_now.ToString("10yyyyMMdd");
                        this.dateBody.DayMain_itemArr[i].DayItemType = (ymd_min > ymd_now || ymd_now > ymd_max) ? DayItemTypes.Disabled : DayItemTypes.UnCurrent;
                    }
                }
            }
        }

        /// <summary>
        /// 更新底部画面文本信息
        /// </summary>
        private void UpdateBottomText()
        {
            string strformat;
            if (this.DateFormat == DatePickerFormats.yyyy)
            {
                strformat = "yyyy";
            }
            else if (this.DateFormat == DatePickerFormats.yyyyMM)
            {
                strformat = "yyyy-MM";
            }
            else
            {
                strformat = "yyyy-MM-dd";
            }

            this.dateBody.Bottombar_mindate_lab.Text = this.MinValue.ToString(strformat);
            this.dateBody.Bottombar_maxdate_lab.Text = this.MaxValue.ToString(strformat);
        }

        /// <summary>
        /// 当前设置格式是否包含日期指定部分
        /// </summary>
        /// <param name="dateElement">日期指定部分</param>
        /// <returns></returns>
        private bool IsContainEmbodyForCurrentFormat(DateElement dateElement)
        {
            switch (dateElement)
            {
                case DateElement.Year:
                    {
                        return (this.DateFormat == DatePickerFormats.yyyy || this.DateFormat == DatePickerFormats.yyyyMM || this.DateFormat == DatePickerFormats.yyyyMMdd || this.DateFormat == DatePickerFormats.yyyyMMddHH || this.DateFormat == DatePickerFormats.yyyyMMddHHmm || this.DateFormat == DatePickerFormats.yyyyMMddHHmmss);
                    }
                case DateElement.Month:
                    {
                        return (this.DateFormat == DatePickerFormats.yyyyMM || this.DateFormat == DatePickerFormats.yyyyMMdd || this.DateFormat == DatePickerFormats.yyyyMMddHH || this.DateFormat == DatePickerFormats.yyyyMMddHHmm || this.DateFormat == DatePickerFormats.yyyyMMddHHmmss);
                    }
                case DateElement.Day:
                    {
                        return (this.DateFormat == DatePickerFormats.yyyyMMdd || this.DateFormat == DatePickerFormats.yyyyMMddHH || this.DateFormat == DatePickerFormats.yyyyMMddHHmm || this.DateFormat == DatePickerFormats.yyyyMMddHHmmss);
                    }
                case DateElement.Hour:
                    {
                        return (this.DateFormat == DatePickerFormats.yyyyMMddHH || this.DateFormat == DatePickerFormats.yyyyMMddHHmm || this.DateFormat == DatePickerFormats.yyyyMMddHHmmss);
                    }
                case DateElement.Minute:
                    {
                        return (this.DateFormat == DatePickerFormats.yyyyMMddHHmm || this.DateFormat == DatePickerFormats.yyyyMMddHHmmss);
                    }
                case DateElement.Second:
                    {
                        return (this.DateFormat == DatePickerFormats.yyyyMMddHHmmss);
                    }
                default:
                    {
                        return false;
                    }
            }
        }

        /// <summary>
        /// 日期指定部分面板是否在当前面板显示  
        /// </summary>
        /// <param name="dateElement">日期指定部分面板</param>
        /// <returns></returns>
        private bool IsContainEmbodyForCurrentView(DateElement dateElement)
        {
            switch (dateElement)
            {
                case DateElement.Year:
                    {
                        return (this.currentDateFormatsViews == DateFormatsViews.Year_Year || this.currentDateFormatsViews == DateFormatsViews.YearMonth_Year || this.currentDateFormatsViews == DateFormatsViews.YearMonthDay_Year);
                    }
                case DateElement.Month:
                    {
                        return (this.currentDateFormatsViews == DateFormatsViews.YearMonth_Month || this.currentDateFormatsViews == DateFormatsViews.YearMonthDay_Month);
                    }
                case DateElement.Day:
                    {
                        return (this.currentDateFormatsViews == DateFormatsViews.YearMonthDay_Day);
                    }
                case DateElement.Hour:
                    {
                        return (this.DateFormat == DatePickerFormats.yyyyMMddHH || this.DateFormat == DatePickerFormats.yyyyMMddHHmm || this.DateFormat == DatePickerFormats.yyyyMMddHHmmss);
                    }
                case DateElement.Minute:
                    {
                        return (this.DateFormat == DatePickerFormats.yyyyMMddHHmm || this.DateFormat == DatePickerFormats.yyyyMMddHHmmss);
                    }
                case DateElement.Second:
                    {
                        return (this.DateFormat == DatePickerFormats.yyyyMMddHHmmss);
                    }
                default:
                    {
                        return false;
                    }
            }
        }

        /// <summary>
        /// 当前面板切换到指定面板
        /// </summary>
        /// <param name="view">指定面板</param>
        private void SetCurrentDateFormatsViews(DateFormatsViews view)
        {
            this.currentDateFormatsViews = view;
            if (this.currentDateFormatsViews == DateFormatsViews.Year_Year)
            {
                this.activatedIndex = 0;
                this.activatedrect = this.dateBody.YearMain_itemArr[0].Rect;
            }
            else if (this.currentDateFormatsViews == DateFormatsViews.YearMonth_Year)
            {
                this.activatedIndex = 0;
                this.activatedrect = this.dateBody.YearMain_itemArr[0].Rect;
            }
            else if (this.currentDateFormatsViews == DateFormatsViews.YearMonth_Month)
            {
                this.activatedIndex = 0;
                this.activatedrect = this.dateBody.MonthMain_itemArr[0].Rect;
            }
            else if (this.currentDateFormatsViews == DateFormatsViews.YearMonthDay_Year)
            {
                this.activatedIndex = 0;
                this.activatedrect = this.dateBody.YearMain_itemArr[0].Rect;
            }
            else if (this.currentDateFormatsViews == DateFormatsViews.YearMonthDay_Month)
            {
                this.activatedIndex = 0;
                this.activatedrect = this.dateBody.MonthMain_itemArr[0].Rect;
            }
            else if (this.currentDateFormatsViews == DateFormatsViews.YearMonthDay_Day)
            {
                this.activatedIndex = 0;
                this.activatedrect = this.dateBody.DayMain_itemArr[0].Rect;
            }
        }

        /// <summary>
        /// 让选中的时间选垂直项居中显示
        /// </summary>
        private void AutoMiddleSelectedTimeItem()
        {
            int scale_time_item_height = (int)(this.time_item_rect_height * this.ScaleDpi);
            int center_y = (int)(this.dateBody.TimeMain_Rect.Y + (this.dateBody.TimeMain_Rect.Height - scale_time_item_height) / 2f);

            if (this.IsContainEmbodyForCurrentFormat(DateElement.Hour))
            {
                if (this.dateBody.selected_hour > -1)
                {
                    int item_y = this.dateBody.TimeMain_HourArea.itemArr[this.dateBody.selected_hour].Rect.Y;
                    if (item_y > center_y)
                    {
                        float offset = ((item_y - center_y) * (this.dateBody.TimeMain_HourArea.Scroll.Scroll_Back_Rect.Height - this.dateBody.TimeMain_HourArea.Scroll.Scroll_Slide_Rect.Height) / (this.dateBody.TimeMain_HourArea.Scroll.Owner_Content_Rect.Height - this.dateBody.TimeMain_HourArea.Scroll.Owner_Display_Rect.Height)) + this.dateBody.TimeMain_HourArea.Scroll.Scroll_Back_Rect.Y - this.dateBody.TimeMain_HourArea.Scroll.Scroll_Slide_Rect.Y;
                        this.dateBody.TimeMain_HourArea.Scroll.IsResetScrollByOffset((int)offset);
                    }
                    else
                    {
                        this.dateBody.TimeMain_HourArea.Scroll.IsResetScrollByOffset(this.GetTimeItemsDisplayY(this.dateBody.TimeMain_HourArea.Scroll));
                    }
                }
            }
            if (this.IsContainEmbodyForCurrentFormat(DateElement.Minute))
            {
                if (this.dateBody.selected_minute > -1)
                {
                    int item_y = this.dateBody.TimeMain_MinuteArea.itemArr[this.dateBody.selected_minute].Rect.Y;
                    if (item_y > center_y)
                    {
                        float offset = ((item_y - center_y) * (this.dateBody.TimeMain_MinuteArea.Scroll.Scroll_Back_Rect.Height - this.dateBody.TimeMain_MinuteArea.Scroll.Scroll_Slide_Rect.Height) / (this.dateBody.TimeMain_MinuteArea.Scroll.Owner_Content_Rect.Height - this.dateBody.TimeMain_MinuteArea.Scroll.Owner_Display_Rect.Height)) + this.dateBody.TimeMain_MinuteArea.Scroll.Scroll_Back_Rect.Y - this.dateBody.TimeMain_MinuteArea.Scroll.Scroll_Slide_Rect.Y;
                        this.dateBody.TimeMain_MinuteArea.Scroll.IsResetScrollByOffset((int)offset);
                    }
                    else
                    {
                        this.dateBody.TimeMain_MinuteArea.Scroll.IsResetScrollByOffset(this.GetTimeItemsDisplayY(this.dateBody.TimeMain_MinuteArea.Scroll));
                    }
                }
            }
            if (this.IsContainEmbodyForCurrentFormat(DateElement.Second))
            {
                if (this.dateBody.selected_second > -1)
                {
                    int item_y = this.dateBody.TimeMain_SecondArea.itemArr[this.dateBody.selected_second].Rect.Y;
                    if (item_y > center_y)
                    {
                        float offset = ((item_y - center_y) * (this.dateBody.TimeMain_SecondArea.Scroll.Scroll_Back_Rect.Height - this.dateBody.TimeMain_SecondArea.Scroll.Scroll_Slide_Rect.Height) / (this.dateBody.TimeMain_SecondArea.Scroll.Owner_Content_Rect.Height - this.dateBody.TimeMain_SecondArea.Scroll.Owner_Display_Rect.Height)) + this.dateBody.TimeMain_SecondArea.Scroll.Scroll_Back_Rect.Y - this.dateBody.TimeMain_SecondArea.Scroll.Scroll_Slide_Rect.Y;
                        this.dateBody.TimeMain_SecondArea.Scroll.IsResetScrollByOffset((int)offset);
                    }
                    else
                    {
                        this.dateBody.TimeMain_SecondArea.Scroll.IsResetScrollByOffset(this.GetTimeItemsDisplayY(this.dateBody.TimeMain_SecondArea.Scroll));
                    }
                }
            }
        }

        /// <summary>
        /// 键盘方向键更新激活索引
        /// </summary>
        /// <param name="key">键盘方向键 Keys.Left、Keys.Right、Keys.Up、Keys.Down</param>
        private void ActivateIndexByKey(Keys key)
        {
            int tmp = this.activatedIndex;
            if (this.currentDateFormatsViews == DateFormatsViews.Year_Year)
            {
                if (key == Keys.Left)
                {
                    tmp -= 1;
                    if (tmp < -2)
                    {
                        tmp = 14;
                    }
                }
                else if (key == Keys.Right)
                {
                    tmp += 1;
                    if (tmp > 14)
                    {
                        tmp = -2;
                    }
                }
                else if (key == Keys.Up)
                {
                    if (tmp <= -1)
                    {
                        tmp = 14;
                    }
                    else if (tmp <= 2)
                    {
                        tmp = -1;
                    }
                    else if (tmp <= 11)
                    {
                        tmp -= 3;
                    }
                    else if (tmp <= 14)
                    {
                        tmp = 11;
                    }
                }
                else if (key == Keys.Down)
                {
                    if (tmp >= 12)
                    {
                        tmp = -2;
                    }
                    else if (tmp >= 9)
                    {
                        tmp = 12;
                    }
                    else if (tmp >= 0)
                    {
                        tmp += 3;
                    }
                    else if (tmp >= -2)
                    {
                        tmp = 0;
                    }
                }

                if (tmp == -2)
                {
                    this.activatedrect = this.dateBody.TopBar_prev_year_btn.Rect;
                }
                else if (tmp == -1)
                {
                    this.activatedrect = this.dateBody.TopBar_next_year_btn.Rect;
                }
                else if (tmp >= 0 && tmp <= 11)
                {
                    this.activatedrect = this.dateBody.YearMain_itemArr[tmp].Rect;
                }
                else if (tmp == 12)
                {
                    this.activatedrect = this.dateBody.Bottombar_clear_btn.Rect;
                }
                else if (tmp == 13)
                {
                    this.activatedrect = this.dateBody.Bottombar_now_btn.Rect;
                }
                else if (tmp == 14)
                {
                    this.activatedrect = this.dateBody.Bottombar_confirm_btn.Rect;
                }
                this.activatedIndex = tmp;
            }
            else if (this.currentDateFormatsViews == DateFormatsViews.YearMonth_Year)
            {
                if (key == Keys.Left)
                {
                    tmp -= 1;
                    if (tmp < -3)
                    {
                        tmp = 14;
                    }
                }
                else if (key == Keys.Right)
                {
                    tmp += 1;
                    if (tmp > 14)
                    {
                        tmp = -3;
                    }
                }
                else if (key == Keys.Up)
                {
                    if (tmp <= -1)
                    {
                        tmp = 14;
                    }
                    else if (tmp <= 2)
                    {
                        tmp = -1;
                    }
                    else if (tmp <= 11)
                    {
                        tmp -= 3;
                    }
                    else if (tmp <= 14)
                    {
                        tmp = 11;
                    }
                }
                else if (key == Keys.Down)
                {
                    if (tmp >= 12)
                    {
                        tmp = -3;
                    }
                    else if (tmp >= 9)
                    {
                        tmp = 12;
                    }
                    else if (tmp >= 0)
                    {
                        tmp += 3;
                    }
                    else if (tmp >= -3)
                    {
                        tmp = 0;
                    }
                }

                if (tmp == -3)
                {
                    this.activatedrect = this.dateBody.TopBar_prev_year_btn.Rect;
                }
                else if (tmp == -2)
                {
                    this.activatedrect = this.dateBody.TopBar_monthyear_btn.Rect;
                }
                else if (tmp == -1)
                {
                    this.activatedrect = this.dateBody.TopBar_next_year_btn.Rect;
                }
                else if (tmp >= 0 && tmp <= 11)
                {
                    this.activatedrect = this.dateBody.YearMain_itemArr[tmp].Rect;
                }
                else if (tmp == 12)
                {
                    this.activatedrect = this.dateBody.Bottombar_clear_btn.Rect;
                }
                else if (tmp == 13)
                {
                    this.activatedrect = this.dateBody.Bottombar_now_btn.Rect;
                }
                else if (tmp == 14)
                {
                    this.activatedrect = this.dateBody.Bottombar_confirm_btn.Rect;
                }
                this.activatedIndex = tmp;
            }
            else if (this.currentDateFormatsViews == DateFormatsViews.YearMonth_Month)
            {
                if (key == Keys.Left)
                {
                    tmp -= 1;
                    if (tmp < -3)
                    {
                        tmp = 14;
                    }
                }
                else if (key == Keys.Right)
                {
                    tmp += 1;
                    if (tmp > 14)
                    {
                        tmp = -3;
                    }
                }
                else if (key == Keys.Up)
                {
                    if (tmp <= -1)
                    {
                        tmp = 14;
                    }
                    else if (tmp <= 2)
                    {
                        tmp = -1;
                    }
                    else if (tmp <= 11)
                    {
                        tmp -= 3;
                    }
                    else if (tmp <= 14)
                    {
                        tmp = 11;
                    }
                }
                else if (key == Keys.Down)
                {
                    if (tmp >= 12)
                    {
                        tmp = -3;
                    }
                    else if (tmp >= 9)
                    {
                        tmp = 12;
                    }
                    else if (tmp >= 0)
                    {
                        tmp += 3;
                    }
                    else if (tmp >= -3)
                    {
                        tmp = 0;
                    }
                }

                if (tmp == -3)
                {
                    this.activatedrect = this.dateBody.TopBar_prev_year_btn.Rect;
                }
                else if (tmp == -2)
                {
                    this.activatedrect = this.dateBody.TopBar_monthyear_btn.Rect;
                }
                else if (tmp == -1)
                {
                    this.activatedrect = this.dateBody.TopBar_next_year_btn.Rect;
                }
                else if (tmp >= 0 && tmp <= 11)
                {
                    this.activatedrect = this.dateBody.MonthMain_itemArr[tmp].Rect;
                }
                else if (tmp == 12)
                {
                    this.activatedrect = this.dateBody.Bottombar_clear_btn.Rect;
                }
                else if (tmp == 13)
                {
                    this.activatedrect = this.dateBody.Bottombar_now_btn.Rect;
                }
                else if (tmp == 14)
                {
                    this.activatedrect = this.dateBody.Bottombar_confirm_btn.Rect;
                }
                this.activatedIndex = tmp;
            }
            else if (this.currentDateFormatsViews == DateFormatsViews.YearMonthDay_Year)
            {
                if (key == Keys.Left)
                {
                    tmp -= 1;
                    if (tmp < -6)
                    {
                        tmp = 14;
                    }
                }
                else if (key == Keys.Right)
                {
                    tmp += 1;
                    if (tmp > 14)
                    {
                        tmp = -6;
                    }
                }
                else if (key == Keys.Up)
                {
                    if (tmp <= -1)
                    {
                        tmp = 14;
                    }
                    else if (tmp <= 2)
                    {
                        tmp = -1;
                    }
                    else if (tmp <= 11)
                    {
                        tmp -= 3;
                    }
                    else if (tmp <= 14)
                    {
                        tmp = 11;
                    }
                }
                else if (key == Keys.Down)
                {
                    if (tmp >= 12)
                    {
                        tmp = -6;
                    }
                    else if (tmp >= 9)
                    {
                        tmp = 12;
                    }
                    else if (tmp >= 0)
                    {
                        tmp += 3;
                    }
                    else if (tmp >= -6)
                    {
                        tmp = 0;
                    }
                }

                if (tmp == -6)
                {
                    this.activatedrect = this.dateBody.TopBar_prev_year_btn.Rect;
                }
                else if (tmp == -5)
                {
                    this.activatedrect = this.dateBody.TopBar_prev_month_btn.Rect;
                }
                else if (tmp == -4)
                {
                    this.activatedrect = this.dateBody.TopBar_month_btn.Rect;
                }
                else if (tmp == -3)
                {
                    this.activatedrect = this.dateBody.TopBar_year_btn.Rect;
                }
                else if (tmp == -2)
                {
                    this.activatedrect = this.dateBody.TopBar_next_month_btn.Rect;
                }
                else if (tmp == -1)
                {
                    this.activatedrect = this.dateBody.TopBar_next_year_btn.Rect;
                }
                else if (tmp >= 0 && tmp <= 11)
                {
                    this.activatedrect = this.dateBody.YearMain_itemArr[tmp].Rect;
                }
                else if (tmp == 12)
                {
                    this.activatedrect = this.dateBody.Bottombar_clear_btn.Rect;
                }
                else if (tmp == 13)
                {
                    this.activatedrect = this.dateBody.Bottombar_now_btn.Rect;
                }
                else if (tmp == 14)
                {
                    this.activatedrect = this.dateBody.Bottombar_confirm_btn.Rect;
                }
                this.activatedIndex = tmp;
            }
            else if (this.currentDateFormatsViews == DateFormatsViews.YearMonthDay_Month)
            {
                if (key == Keys.Left)
                {
                    tmp -= 1;
                    if (tmp < -6)
                    {
                        tmp = 14;
                    }
                }
                else if (key == Keys.Right)
                {
                    tmp += 1;
                    if (tmp > 14)
                    {
                        tmp = -6;
                    }
                }
                else if (key == Keys.Up)
                {
                    if (tmp <= -1)
                    {
                        tmp = 14;
                    }
                    else if (tmp <= 2)
                    {
                        tmp = -1;
                    }
                    else if (tmp <= 11)
                    {
                        tmp -= 3;
                    }
                    else if (tmp <= 14)
                    {
                        tmp = 11;
                    }
                }
                else if (key == Keys.Down)
                {
                    if (tmp >= 12)
                    {
                        tmp = -6;
                    }
                    else if (tmp >= 9)
                    {
                        tmp = 12;
                    }
                    else if (tmp >= 0)
                    {
                        tmp += 3;
                    }
                    else if (tmp >= -6)
                    {
                        tmp = 0;
                    }
                }

                if (tmp == -6)
                {
                    this.activatedrect = this.dateBody.TopBar_prev_year_btn.Rect;
                }
                else if (tmp == -5)
                {
                    this.activatedrect = this.dateBody.TopBar_prev_month_btn.Rect;
                }
                else if (tmp == -4)
                {
                    this.activatedrect = this.dateBody.TopBar_month_btn.Rect;
                }
                else if (tmp == -3)
                {
                    this.activatedrect = this.dateBody.TopBar_year_btn.Rect;
                }
                else if (tmp == -2)
                {
                    this.activatedrect = this.dateBody.TopBar_next_month_btn.Rect;
                }
                else if (tmp == -1)
                {
                    this.activatedrect = this.dateBody.TopBar_next_year_btn.Rect;
                }
                else if (tmp >= 0 && tmp <= 11)
                {
                    this.activatedrect = this.dateBody.MonthMain_itemArr[tmp].Rect;
                }
                else if (tmp == 12)
                {
                    this.activatedrect = this.dateBody.Bottombar_clear_btn.Rect;
                }
                else if (tmp == 13)
                {
                    this.activatedrect = this.dateBody.Bottombar_now_btn.Rect;
                }
                else if (tmp == 14)
                {
                    this.activatedrect = this.dateBody.Bottombar_confirm_btn.Rect;
                }
                this.activatedIndex = tmp;
            }
            else if (this.currentDateFormatsViews == DateFormatsViews.YearMonthDay_Day)
            {
                if (key == Keys.Left)
                {
                    tmp -= 1;
                    if (tmp < -6)
                    {
                        tmp = 44;
                    }
                }
                else if (key == Keys.Right)
                {
                    tmp += 1;
                    if (tmp > 44)
                    {
                        tmp = -6;
                    }
                }
                else if (key == Keys.Up)
                {
                    if (tmp <= -1)
                    {
                        tmp = 44;
                    }
                    else if (tmp <= 6)
                    {
                        tmp = -1;
                    }
                    else if (tmp <= 41)
                    {
                        tmp -= 7;
                    }
                    else if (tmp <= 44)
                    {
                        tmp = 41;
                    }
                }
                else if (key == Keys.Down)
                {
                    if (tmp >= 41)
                    {
                        tmp = -6;
                    }
                    else if (tmp >= 35)
                    {
                        tmp = 42;
                    }
                    else if (tmp >= 0)
                    {
                        tmp += 7;
                    }
                    else if (tmp >= -6)
                    {
                        tmp = 0;
                    }
                }

                if (tmp == -6)
                {
                    this.activatedrect = this.dateBody.TopBar_prev_year_btn.Rect;
                }
                else if (tmp == -5)
                {
                    this.activatedrect = this.dateBody.TopBar_prev_month_btn.Rect;
                }
                else if (tmp == -4)
                {
                    this.activatedrect = this.dateBody.TopBar_month_btn.Rect;
                }
                else if (tmp == -3)
                {
                    this.activatedrect = this.dateBody.TopBar_year_btn.Rect;
                }
                else if (tmp == -2)
                {
                    this.activatedrect = this.dateBody.TopBar_next_month_btn.Rect;
                }
                else if (tmp == -1)
                {
                    this.activatedrect = this.dateBody.TopBar_next_year_btn.Rect;
                }
                else if (tmp >= 0 && tmp <= 41)
                {
                    this.activatedrect = this.dateBody.DayMain_itemArr[tmp].Rect;
                }
                else if (tmp == 42)
                {
                    this.activatedrect = this.dateBody.Bottombar_clear_btn.Rect;
                }
                else if (tmp == 43)
                {
                    this.activatedrect = this.dateBody.Bottombar_now_btn.Rect;
                }
                else if (tmp == 44)
                {
                    this.activatedrect = this.dateBody.Bottombar_confirm_btn.Rect;
                }
                this.activatedIndex = tmp;
            }

            this.activatedVisible = true;
            this.Invalidate();
        }

        /// <summary>
        ///指定激活选项单击
        /// </summary>
        /// <returns></returns>
        private void ActivateIndexClick()
        {
            int index = this.activatedIndex;

            if (this.currentDateFormatsViews == DateFormatsViews.Year_Year)
            {
                if (index == -2)
                {
                    this.TopBarPrevYearClick();
                }
                else if (index == -1)
                {
                    this.TopBarNextYearClick();
                }
                else if (0 <= index && index <= 11)
                {
                    this.YearMainItemClick(this.dateBody.YearMain_itemArr[index]);
                }
                else if (index == 12)
                {
                    this.OnBottomBarClearClick(new EventArgs());
                }
                else if (index == 13)
                {
                    this.OnBottomBarNowClick(new EventArgs());
                }
                else if (index == 14)
                {
                    this.OnBottomBarConfirmClick(new EventArgs());
                }
            }
            else if (this.currentDateFormatsViews == DateFormatsViews.YearMonth_Year)
            {
                if (index == -3)
                {
                    this.TopBarPrevYearClick();
                }
                else if (index == -2)
                {
                    this.TopBarYearMonthClick();
                }
                else if (index == -1)
                {
                    this.TopBarNextYearClick();
                }
                else if (0 <= index && index <= 11)
                {
                    this.MonthMainItemClick(this.dateBody.YearMain_itemArr[index]);
                }
                else if (index == 12)
                {
                    this.OnBottomBarClearClick(new EventArgs());
                }
                else if (index == 13)
                {
                    this.OnBottomBarNowClick(new EventArgs());
                }
                else if (index == 14)
                {
                    this.OnBottomBarConfirmClick(new EventArgs());
                }
            }
            else if (this.currentDateFormatsViews == DateFormatsViews.YearMonth_Month)
            {
                if (index == -3)
                {
                    this.TopBarPrevYearClick();
                }
                else if (index == -2)
                {
                    this.TopBarYearMonthClick();
                }
                else if (index == -1)
                {
                    this.TopBarNextYearClick();
                }
                else if (0 <= index && index <= 11)
                {
                    this.YearMainItemClick(this.dateBody.MonthMain_itemArr[index]);
                }
                else if (index == 12)
                {
                    this.OnBottomBarClearClick(new EventArgs());
                }
                else if (index == 13)
                {
                    this.OnBottomBarNowClick(new EventArgs());
                }
                else if (index == 14)
                {
                    this.OnBottomBarConfirmClick(new EventArgs());
                }
            }
            else if (this.currentDateFormatsViews == DateFormatsViews.YearMonthDay_Year)
            {
                if (index == -6)
                {
                    this.TopBarPrevYearClick();
                }
                else if (index == -5)
                {
                    this.TopBarPrevMonthClick();
                }
                else if (index == -4)
                {
                    this.TopBarMonthClick();
                }
                else if (index == -3)
                {
                    this.TopBarYearClick();
                }
                else if (index == -2)
                {
                    this.TopBarNextMonthClick();
                }
                else if (index == -1)
                {
                    this.TopBarNextYearClick();
                }
                else if (0 <= index && index <= 11)
                {
                    this.YearMainItemClick(this.dateBody.YearMain_itemArr[index]);
                }
                else if (index == 12)
                {
                    this.OnBottomBarClearClick(new EventArgs());
                }
                else if (index == 13)
                {
                    this.OnBottomBarNowClick(new EventArgs());
                }
                else if (index == 14)
                {
                    this.OnBottomBarConfirmClick(new EventArgs());
                }
            }
            else if (this.currentDateFormatsViews == DateFormatsViews.YearMonthDay_Month)
            {
                if (index == -6)
                {
                    this.TopBarPrevYearClick();
                }
                else if (index == -5)
                {
                    this.TopBarPrevMonthClick();
                }
                else if (index == -4)
                {
                    this.TopBarMonthClick();
                }
                else if (index == -3)
                {
                    this.TopBarYearClick();
                }
                else if (index == -2)
                {
                    this.TopBarNextMonthClick();
                }
                else if (index == -1)
                {
                    this.TopBarNextYearClick();
                }
                else if (0 <= index && index <= 11)
                {
                    this.MonthMainItemClick(this.dateBody.MonthMain_itemArr[index]);
                }
                else if (index == 12)
                {
                    this.OnBottomBarClearClick(new EventArgs());
                }
                else if (index == 13)
                {
                    this.OnBottomBarNowClick(new EventArgs());
                }
                else if (index == 14)
                {
                    this.OnBottomBarConfirmClick(new EventArgs());
                }
                this.UpdateTopText();
                this.UpdateYearMonthDayText();
                this.Invalidate();
            }
            else if (this.currentDateFormatsViews == DateFormatsViews.YearMonthDay_Day)
            {
                if (index == -6)
                {
                    this.TopBarPrevYearClick();
                }
                else if (index == -5)
                {
                    this.TopBarPrevMonthClick();
                }
                else if (index == -4)
                {
                    this.TopBarMonthClick();
                }
                else if (index == -3)
                {
                    this.TopBarYearClick();
                }
                else if (index == -2)
                {
                    this.TopBarNextMonthClick();
                }
                else if (index == -1)
                {
                    this.TopBarNextYearClick();
                }
                else if (index <= 41)
                {
                    this.DayMainItemClick(this.dateBody.DayMain_itemArr[index]);
                }
                else if (index == 42)
                {
                    this.OnBottomBarClearClick(new EventArgs());
                }
                else if (index == 43)
                {
                    this.OnBottomBarNowClick(new EventArgs());
                }
                else if (index == 44)
                {
                    this.OnBottomBarConfirmClick(new EventArgs());
                }
            }
        }

        /// <summary>
        /// 根据设置获取控件大小
        /// </summary>
        /// <returns></returns>
        private Size GetControlAutoSize()
        {
            int scale_date_rect_width = (int)(this.mainbar_rect_width * this.ScaleDpi);
            int scale_date_rect_height = (int)(this.mainbar_rect_height * this.ScaleDpi);
            int scale_topbar_rect_height = (int)(this.topbar_rect_height * this.ScaleDpi);
            int scale_bottombar_rect_height = (int)(this.bottombar_rect_height * this.ScaleDpi);

            int scale_time_rect_width = 0;
            if (this.DateFormat == DatePickerFormats.yyyyMMddHH)
            {
                scale_time_rect_width = date_time_rect_space + (int)((this.time_item_rect_width + this.time_scroll_thickness) * this.ScaleDpi);
            }
            else if (this.DateFormat == DatePickerFormats.yyyyMMddHHmm)
            {
                scale_time_rect_width = date_time_rect_space + (int)((this.time_item_rect_width + this.time_scroll_thickness) * 2 * this.ScaleDpi);
            }
            else if (this.DateFormat == DatePickerFormats.yyyyMMddHHmmss)
            {
                scale_time_rect_width = date_time_rect_space + (int)((this.time_item_rect_width + this.time_scroll_thickness) * 3 * this.ScaleDpi);
            }

            return new Size(scale_date_rect_width + scale_time_rect_width, scale_topbar_rect_height + scale_date_rect_height + scale_bottombar_rect_height);
        }

        /// <summary>
        /// 获取指定年份的年面板第一个开始的年份
        /// </summary>
        /// <param name="year">指定年份</param>
        /// <returns></returns>
        private int GetStartYaer(int year)
        {
            return Math.Min(Math.Max(year - 4, 1), 9988);
        }

        /// <summary>
        /// 获取时间选项列表Rect的开始Y坐标
        /// </summary>
        /// <param name="scroll_obj"></param>
        /// <returns></returns>
        private int GetTimeItemsDisplayY(TimeAreaScrollClass scroll_obj)
        {
            float y = 0;
            if (scroll_obj.Scroll_Back_Rect.Height > scroll_obj.Scroll_Slide_Rect.Height)
            {
                y = -(scroll_obj.Scroll_Slide_Rect.Y - scroll_obj.Scroll_Back_Rect.Y) / (scroll_obj.Scroll_Back_Rect.Height - scroll_obj.Scroll_Slide_Rect.Height) * (scroll_obj.Owner_Content_Rect.Height - scroll_obj.Owner_Display_Rect.Height);
            }
            return (int)(y);
        }

        /// <summary>
        /// 绘制时间滚动条
        /// </summary>
        /// <param name="g"></param>
        /// <param name="scroll_obj">时间滚动条对象</param>
        /// <param name="scroll_back_pen">滚动条背景画笔</param>
        /// <param name="scroll_slide_pen">滚动条滑块画笔</param>
        private void DrawTimeScroll(Graphics g, TimeAreaScrollClass scroll_obj, Pen scroll_back_pen, Pen scroll_slide_pen)
        {
            if (scroll_obj.Scroll_Back_Rect.Height > scroll_obj.Scroll_Slide_Rect.Height)
            {
                // 滚动条背景
                PointF scroll_start_point = new PointF(scroll_obj.Scroll_Back_Rect.X + scroll_back_pen.Width / 2f, scroll_obj.Scroll_Back_Rect.Y);
                PointF scroll_end_point = new PointF(scroll_obj.Scroll_Back_Rect.X + scroll_back_pen.Width / 2f, scroll_obj.Scroll_Back_Rect.Bottom);
                g.DrawLine(scroll_back_pen, scroll_start_point, scroll_end_point);

                //  滚动条滑块
                PointF scroll_slide_start_point = new PointF(scroll_obj.Scroll_Slide_Rect.X + scroll_back_pen.Width / 2f, scroll_obj.Scroll_Slide_Rect.Y);
                PointF scroll_slide_end_point = new PointF(scroll_obj.Scroll_Slide_Rect.X + scroll_back_pen.Width / 2f, scroll_obj.Scroll_Slide_Rect.Bottom);
                g.DrawLine(scroll_slide_pen, scroll_slide_start_point, scroll_slide_end_point);
            }
        }

        /// <summary>
        /// 上一年
        /// </summary>
        private void TopBarPrevYearClick()
        {
            if (this.DateFormat == DatePickerFormats.yyyy)
            {
                this.dateBody.current_display_year -= 12;
            }
            else
            {
                this.dateBody.current_display_year -= 1;
            }
            if (this.dateBody.current_display_year < 1)
            {
                this.dateBody.current_display_year = 1;
            }

            this.UpdateTopText();
            this.UpdateYearMonthDayText();
            this.Invalidate();
        }
        /// <summary>
        /// 上一月
        /// </summary>
        private void TopBarPrevMonthClick()
        {
            if (this.IsContainEmbodyForCurrentFormat(DateElement.Day))
            {
                DateTime tmp = new DateTime(this.dateBody.current_display_year, this.dateBody.current_display_month, 1).AddMonths(-1);
                this.dateBody.current_display_month = tmp.Month;
            }

            this.UpdateTopText();
            this.UpdateYearMonthDayText();
            this.Invalidate();
        }
        /// <summary>
        /// 年月切换面板
        /// </summary>
        private void TopBarYearMonthClick()
        {
            if (this.currentDateFormatsViews == DateFormatsViews.YearMonth_Year)
            {
                this.SetCurrentDateFormatsViews(DateFormatsViews.YearMonth_Month);
            }
            else
            {
                this.SetCurrentDateFormatsViews(DateFormatsViews.YearMonth_Year);
            }

            this.Invalidate();
        }
        /// <summary>
        /// 显示月面板
        /// </summary>
        private void TopBarMonthClick()
        {
            if (this.IsContainEmbodyForCurrentFormat(DateElement.Day))
            {
                if (this.currentDateFormatsViews == DateFormatsViews.YearMonthDay_Month)
                {
                    this.SetCurrentDateFormatsViews(DateFormatsViews.YearMonthDay_Day);
                }
                else
                {
                    this.SetCurrentDateFormatsViews(DateFormatsViews.YearMonthDay_Month);
                }
            }

            this.Invalidate();
        }
        /// <summary>
        /// 显示年面板
        /// </summary>
        private void TopBarYearClick()
        {
            if (this.IsContainEmbodyForCurrentFormat(DateElement.Day))
            {
                if (this.currentDateFormatsViews == DateFormatsViews.YearMonthDay_Year)
                {
                    this.SetCurrentDateFormatsViews(DateFormatsViews.YearMonthDay_Day);
                }
                else
                {
                    this.SetCurrentDateFormatsViews(DateFormatsViews.YearMonthDay_Year);
                }
            }

            this.Invalidate();
        }
        /// <summary>
        /// 下一月
        /// </summary>
        private void TopBarNextMonthClick()
        {
            DateTime tmp = new DateTime(this.dateBody.current_display_year, this.dateBody.current_display_month, 1).AddMonths(1);
            this.dateBody.current_display_month = tmp.Month;

            this.UpdateTopText();
            this.UpdateYearMonthDayText();
            this.Invalidate();
        }
        /// <summary>
        /// 下一年
        /// </summary>
        private void TopBarNextYearClick()
        {
            if (this.DateFormat == DatePickerFormats.yyyy)
            {
                this.dateBody.current_display_year += 12;
            }
            else
            {
                this.dateBody.current_display_year += 1;
            }
            if (this.dateBody.current_display_year > 9999)
            {
                this.dateBody.current_display_year = 9999;
            }

            this.UpdateTopText();
            this.UpdateYearMonthDayText();
            this.Invalidate();
        }
        /// <summary>
        /// 年面板年选项单击
        /// </summary>
        /// <param name="e"></param>
        private void YearMainItemClick(DateItemClass e)
        {
            if (this.currentDateFormatsViews == DateFormatsViews.Year_Year)
            {
                this.dateBody.selected_year = int.Parse(e.Value.Substring(2, 4));
            }
            else if (this.currentDateFormatsViews == DateFormatsViews.YearMonth_Year)
            {
                this.dateBody.current_display_year = int.Parse(e.Value.Substring(2, 4));
                this.SetCurrentDateFormatsViews(DateFormatsViews.YearMonth_Month);
            }
            else if (this.currentDateFormatsViews == DateFormatsViews.YearMonthDay_Year)
            {
                this.dateBody.current_display_year = int.Parse(e.Value.Substring(2, 4));
                this.SetCurrentDateFormatsViews(DateFormatsViews.YearMonthDay_Day);
            }

            this.UpdateTopText();
            this.UpdateYearMonthDayText();
            this.Invalidate();
        }
        /// <summary>
        /// 月面板月选项单击
        /// </summary>
        /// <param name="e"></param>
        private void MonthMainItemClick(DateItemClass e)
        {
            if (this.currentDateFormatsViews == DateFormatsViews.YearMonth_Month)
            {
                this.dateBody.selected_year = int.Parse(e.Value.Substring(2, 4));
                this.dateBody.selected_month = int.Parse(e.Value.Substring(6, 2));
            }
            else if (this.currentDateFormatsViews == DateFormatsViews.YearMonthDay_Month)
            {
                this.dateBody.current_display_month = int.Parse(e.Value.Substring(6, 2));
                this.SetCurrentDateFormatsViews(DateFormatsViews.YearMonthDay_Day);
            }

            this.UpdateTopText();
            this.UpdateYearMonthDayText();
            this.Invalidate();
        }
        /// <summary>
        /// 日月面板日选项单击
        /// </summary>
        /// <param name="e"></param>
        private void DayMainItemClick(DateItemClass e)
        {
            this.dateBody.selected_year = int.Parse(e.Value.Substring(2, 4));
            this.dateBody.selected_month = int.Parse(e.Value.Substring(6, 2));
            this.dateBody.selected_day = int.Parse(e.Value.Substring(8, 2));

            this.UpdateTopText();
            this.UpdateYearMonthDayText();
            this.Invalidate();
        }

        /// <summary>
        /// 绘制Rectangle左边圆角（圆角边框半径为3个像素）
        /// </summary>
        /// <param name="g">要绘制边框的控件画布</param>
        /// <param name="rect">要绘制边框的rect</param>
        /// <param name="backColor">背景色</param>
        /// <param name="backOverColor">背景色平滑过度颜色</param>
        public void DrawLeftBorder(Graphics g, Rectangle rect, Color backColor, Color backOverColor)
        {
            SmoothingMode smoothingMode = g.SmoothingMode;
            CompositingMode compositingMode = g.CompositingMode;
            CompositingQuality compositingQuality = g.CompositingQuality;
            InterpolationMode interpolationMode = g.InterpolationMode;

            g.SmoothingMode = SmoothingMode.None;
            g.CompositingMode = CompositingMode.SourceCopy;
            g.CompositingQuality = CompositingQuality.Default;
            g.InterpolationMode = InterpolationMode.Default;



            //背景
            SolidBrush border_sb = new SolidBrush(backColor);
            g.FillPolygon(border_sb, new Point[] {
                   new Point(rect.Left,rect.Top+1),
                   new Point(rect.Left+1,rect.Top+1),
                   new Point(rect.Left+1,rect.Top),

                   new Point(rect.Right,rect.Top),

                   new Point(rect.Right,rect.Bottom),

                   new Point(rect.Left+1,rect.Bottom-1),
                   new Point(rect.Left+1,rect.Bottom-1-1),
                   new Point(rect.Left,rect.Bottom-1-1),
                 });
            border_sb.Dispose();

            //背景圆角外平滑过度
            Pen border_pen = new Pen(Color.FromArgb(backColor.R + (backOverColor.R - backColor.R) / 4, backColor.G + (backOverColor.G - backColor.G) / 4, backColor.B + (backOverColor.B - backColor.B) / 4));
            g.DrawLine(border_pen, new Point(rect.Left, rect.Top + 1), new Point(rect.Left + 1, rect.Top));
            g.DrawLine(border_pen, new Point(rect.Left + 1, rect.Bottom - 1), new Point(rect.Left, rect.Bottom - 1 - 1));
            border_pen.Dispose();



            g.SmoothingMode = smoothingMode;
            g.CompositingMode = compositingMode;
            g.CompositingQuality = compositingQuality;
            g.InterpolationMode = interpolationMode;
        }

        /// <summary>
        /// 绘制Rectangle右边圆角（圆角边框半径为3个像素）
        /// </summary>
        /// <param name="g">要绘制边框的控件画布</param>
        /// <param name="rect">要绘制边框的rect</param>
        /// <param name="backColor">背景色</param>
        /// <param name="backOverColor">背景色平滑过度颜色</param>
        public void DrawRightBorder(Graphics g, Rectangle rect, Color backColor, Color backOverColor)
        {
            SmoothingMode smoothingMode = g.SmoothingMode;
            CompositingMode compositingMode = g.CompositingMode;
            CompositingQuality compositingQuality = g.CompositingQuality;
            InterpolationMode interpolationMode = g.InterpolationMode;

            g.SmoothingMode = SmoothingMode.None;
            g.CompositingMode = CompositingMode.SourceCopy;
            g.CompositingQuality = CompositingQuality.Default;
            g.InterpolationMode = InterpolationMode.Default;



            //背景
            SolidBrush border_sb = new SolidBrush(backColor);
            g.FillPolygon(border_sb, new Point[] {
                   new Point(rect.Left,rect.Top),

                   new Point(rect.Right-1,rect.Top),
                   new Point(rect.Right-1,rect.Top+1),
                   new Point(rect.Right,rect.Top+1),

                   new Point(rect.Right,rect.Bottom-1),
                   new Point(rect.Right-1,rect.Bottom-1),
                   new Point(rect.Right-1,rect.Bottom),

                   new Point(rect.Left,rect.Bottom),
                 });
            border_sb.Dispose();

            //背景圆角外平滑过度
            Pen border_pen = new Pen(Color.FromArgb(backColor.R + (backOverColor.R - backColor.R) / 4, backColor.G + (backOverColor.G - backColor.G) / 4, backColor.B + (backOverColor.B - backColor.B) / 4));
            g.DrawLine(border_pen, new Point(rect.Right - 1 - 1, rect.Top), new Point(rect.Right - 1, rect.Top + 1));
            g.DrawLine(border_pen, new Point(rect.Right - 1, rect.Bottom - 1 - 1), new Point(rect.Right - 1 - 1, rect.Bottom - 1));
            border_pen.Dispose();



            g.SmoothingMode = smoothingMode;
            g.CompositingMode = compositingMode;
            g.CompositingQuality = compositingQuality;
            g.InterpolationMode = interpolationMode;
        }

        #endregion

        #region 枚举

        /// <summary>
        /// 组成日期的元素
        /// </summary>
        internal enum DateElement
        {
            /// <summary>
            /// 年
            /// </summary>
            Year,
            /// <summary>
            /// 月
            /// </summary>
            Month,
            /// <summary>
            /// 日
            /// </summary>
            Day,
            /// <summary>
            /// 时
            /// </summary>
            Hour,
            /// <summary>
            /// 分
            /// </summary>
            Minute,
            /// <summary>
            /// 秒
            /// </summary>
            Second
        }

        /// <summary>
        /// 在指定显示功能类型下面板显示状态
        /// </summary>
        internal enum DateFormatsViews
        {
            /// <summary>
            /// 年功能中(年面板)
            /// </summary>
            Year_Year,
            /// <summary>
            /// 年月功能中(年面板)
            /// </summary>
            YearMonth_Year,
            /// <summary>
            /// 年月功能中(月面板)
            /// </summary>
            YearMonth_Month,
            /// <summary>
            /// 年月日功能中(年面板)
            /// </summary>
            YearMonthDay_Year,
            /// <summary>
            /// 年月日功能中(月面板)
            /// </summary>
            YearMonthDay_Month,
            /// <summary>
            /// 年月日功能中(日面板)
            /// </summary>
            YearMonthDay_Day
        }

        /// <summary>
        /// 日选项类型
        /// </summary>
        internal enum DayItemTypes
        {
            /// <summary>
            /// 不在最大最小值范围的日期
            /// </summary>
            Disabled,
            /// <summary>
            /// 在日期最大最小值范围,但非本月的日期
            /// </summary>
            UnCurrent,
            /// <summary>
            /// 在日期最大最小值范围,本月的日期
            /// </summary>
            Normal
        }

        #endregion

        #region 类

        /// <summary>
        /// 日期存放信息
        /// </summary>]
        internal class DateBodyClass
        {
            public DateBodyClass()
            {
                this.TopBar_prev_year_btn = new TopBarItemClass();
                this.TopBar_prev_month_btn = new TopBarItemClass();
                this.TopBar_yearscope_btn = new TopBarItemClass();
                this.TopBar_monthyear_btn = new TopBarItemClass();
                this.TopBar_month_btn = new TopBarItemClass();
                this.TopBar_year_btn = new TopBarItemClass();
                this.TopBar_next_month_btn = new TopBarItemClass();
                this.TopBar_next_year_btn = new TopBarItemClass();
                this.Bottombar_minmaxborder_lab = new BottomBarItemClass();
                this.Bottombar_mindate_lab = new BottomBarItemClass();
                this.Bottombar_maxdate_lab = new BottomBarItemClass();

                this.YearMain_itemArr = new DateItemClass[12];
                for (int i = 0; i < this.YearMain_itemArr.Length; i++)
                {
                    this.YearMain_itemArr[i] = new DateItemClass();
                }

                this.MonthMain_itemArr = new DateItemClass[12];
                for (int i = 0; i < this.MonthMain_itemArr.Length; i++)
                {
                    this.MonthMain_itemArr[i] = new DateItemClass();
                }

                string[] days_titles = new string[] { "日", "一", "二", "三", "四", "五", "六" };
                this.DayMain_titleArr = new DayTitleItemClass[days_titles.Length];
                for (int i = 0; i < this.DayMain_titleArr.Length; i++)
                {
                    this.DayMain_titleArr[i] = new DayTitleItemClass() { Text = days_titles[i] };
                }

                this.DayMain_itemArr = new DateItemClass[42];
                for (int i = 0; i < this.DayMain_itemArr.Length; i++)
                {
                    this.DayMain_itemArr[i] = new DateItemClass();
                }

                this.TimeMain_HourArea = new TimeAreaClass(24);
                this.TimeMain_MinuteArea = new TimeAreaClass(60);
                this.TimeMain_SecondArea = new TimeAreaClass(60);

                this.Bottombar_clear_btn = new BottomBarItemClass() { Text = "清除" };
                this.Bottombar_now_btn = new BottomBarItemClass() { Text = "现在" };
                this.Bottombar_confirm_btn = new BottomBarItemClass() { Text = "确认" };

                this.current_display_year = -1;
                this.current_display_month = -1;
            }

            #region 顶部工具栏

            /// <summary>
            /// 顶部工具栏rect
            /// </summary>
            public Rectangle TopBar_Rect { get; set; }

            /// <summary>
            /// 顶部工具栏日期rect
            /// </summary>
            public Rectangle TopBar_Date_Rect { get; set; }
            /// <summary>
            /// 顶部工具栏.上一年按钮
            /// </summary>
            internal TopBarItemClass TopBar_prev_year_btn { get; set; }
            /// <summary>
            /// 顶部工具栏.上一月按钮
            /// </summary>
            internal TopBarItemClass TopBar_prev_month_btn { get; set; }
            /// <summary>
            /// 顶部工具栏.年范围描述
            /// </summary>
            internal TopBarItemClass TopBar_yearscope_btn { get; set; }
            /// <summary>
            /// 顶部工具栏.年、月面板年按钮
            /// </summary>
            internal TopBarItemClass TopBar_monthyear_btn { get; set; }
            /// <summary>
            /// 顶部工具栏.月按钮
            /// </summary>
            internal TopBarItemClass TopBar_month_btn { get; set; }
            /// <summary>
            /// 顶部工具栏.年按钮
            /// </summary>
            internal TopBarItemClass TopBar_year_btn { get; set; }
            /// <summary>
            /// 顶部工具栏.下一月按钮
            /// </summary>
            internal TopBarItemClass TopBar_next_month_btn { get; set; }
            /// <summary>
            /// 顶部工具栏.下一年按钮
            /// </summary>
            internal TopBarItemClass TopBar_next_year_btn { get; set; }

            /// <summary>
            /// 顶部工具栏时间rect
            /// </summary>
            public Rectangle TopBar_Time_Rect { get; set; }
            /// <summary>
            ///  时标题rect
            /// </summary>
            public Rectangle TopBar_hour_rect { get; set; }
            /// <summary>
            ///  分标题rect
            /// </summary>
            public Rectangle TopBar_minute_rect { get; set; }
            /// <summary>
            ///  秒标题rect
            /// </summary>
            public Rectangle TopBar_second_rect { get; set; }

            #endregion

            #region 主面板

            /// <summary>
            /// 主面板.rect
            /// </summary>
            public Rectangle MainBar_Rect { get; set; }

            /// <summary>
            /// 年面板.rect
            /// </summary>
            public Rectangle YearMain_Rect { get; set; }
            /// <summary>
            /// 年面板.选项列表
            /// </summary>
            internal DateItemClass[] YearMain_itemArr { get; set; }

            /// <summary>
            /// 月面板.rect
            /// </summary>
            public Rectangle MonthMain_Rect { get; set; }
            /// <summary>
            /// 月面板.选项列表
            /// </summary>
            internal DateItemClass[] MonthMain_itemArr { get; set; }

            /// <summary>
            /// 日面板.rect
            /// </summary>
            internal Rectangle DayMain_Rect { get; set; }
            /// <summary>
            /// 日面板.标题列表
            /// </summary>
            internal DayTitleItemClass[] DayMain_titleArr { get; set; }
            /// <summary>
            /// 日面板.选项列表
            /// </summary>
            internal DateItemClass[] DayMain_itemArr { get; set; }

            /// <summary>
            ///  时间面板rect
            /// </summary>
            public Rectangle TimeMain_Rect { get; set; }
            /// <summary>
            /// 时间面板时区域
            /// </summary>
            internal TimeAreaClass TimeMain_HourArea { get; set; }
            /// <summary>
            /// 时间面板分区域
            /// </summary>
            internal TimeAreaClass TimeMain_MinuteArea { get; set; }
            /// <summary>
            /// 时间面板秒区域
            /// </summary>
            internal TimeAreaClass TimeMain_SecondArea { get; set; }

            #endregion

            #region 底部工具栏
            /// <summary>
            /// 底部工具栏rect
            /// </summary>
            public Rectangle BottomBar_Rect { get; set; }
            /// <summary>
            /// 底部工具栏最小时间最大时间线
            /// </summary>
            internal BottomBarItemClass Bottombar_minmaxborder_lab { get; set; }
            /// <summary>
            /// 底部工具栏最小时间文本
            /// </summary>
            internal BottomBarItemClass Bottombar_mindate_lab { get; set; }
            /// <summary>
            /// 底部工具栏最大时间文本
            /// </summary>
            internal BottomBarItemClass Bottombar_maxdate_lab { get; set; }
            /// <summary>
            /// 底部工具栏清除按钮
            /// </summary>
            internal BottomBarItemClass Bottombar_clear_btn { get; set; }
            /// <summary>
            /// 底部工具栏现在按钮
            /// </summary>
            internal BottomBarItemClass Bottombar_now_btn { get; set; }
            /// <summary>
            /// 底部工具栏确认按钮
            /// </summary>
            internal BottomBarItemClass Bottombar_confirm_btn { get; set; }

            #endregion

            #region 临时存放

            /// <summary>
            /// 已选择年
            /// </summary>
            internal int selected_year { get; set; }
            /// <summary>
            /// 已选择月
            /// </summary>
            internal int selected_month { get; set; }
            /// <summary>
            /// 已选择日
            /// </summary>
            internal int selected_day { get; set; }
            /// <summary>
            /// 已选择时
            /// </summary>
            internal int selected_hour { get; set; }
            /// <summary>
            /// 已选择分
            /// </summary>
            internal int selected_minute { get; set; }
            /// <summary>
            /// 已选择秒
            /// </summary>
            internal int selected_second { get; set; }

            /// <summary>
            /// 当前年份面板(画面上切换到指定年份的日期提供用户选择)
            /// </summary>
            internal int current_display_year { get; set; }
            /// <summary>
            /// 当前月份面板(画面上切换到指定月份的日期提供用户选择)
            /// </summary>
            internal int current_display_month { get; set; }

            #endregion
        }

        /// <summary>
        /// 顶部工具栏面板选项
        /// </summary>
        internal class TopBarItemClass
        {
            /// <summary>
            /// 顶部工具栏选项rect
            /// </summary>
            public Rectangle Rect { get; set; }

            /// <summary>
            /// 顶部工具栏选项文本
            /// </summary>
            public string Text { get; set; }

            /// <summary>
            /// 顶部工具栏选项按钮图形路径
            /// </summary>
            public Point[] LineLeftPointArr { get; set; }

            /// <summary>
            /// 顶部工具栏选项按钮图形路径
            /// </summary>
            public Point[] LineRightPointArr { get; set; }

        }

        /// <summary>
        /// 年、月、日 选项
        /// </summary>
        internal class DateItemClass
        {
            public DateItemClass()
            {
                this.DayItemType = DayItemTypes.Normal;
            }

            /// <summary>
            /// 选项rect
            /// </summary>]
            public Rectangle Rect { get; set; }

            /// <summary>
            /// 年、月、日 选项值(存储格式：[10yyyy]、[10yyyyMM]、[10yyyyMMdd] )
            /// </summary>
            public string Value { get; set; }

            /// <summary>
            /// 日选项类型(只适用日选项)
            /// </summary>
            internal DayItemTypes DayItemType { get; set; }
        }

        /// <summary>
        /// 日期标题
        /// </summary>
        internal class DayTitleItemClass
        {
            /// <summary>
            /// 日标题.rect
            /// </summary>]
            public Rectangle Rect { get; set; }

            /// <summary>
            /// 日标题.文本
            /// </summary>
            public string Text { get; set; }

        }

        /// <summary>
        /// 时间面板指定区域
        /// </summary>
        internal class TimeAreaClass
        {
            /// <summary>
            /// 
            /// </summary>
            /// <param name="itemcount">选项数量</param>
            public TimeAreaClass(int itemcount)
            {
                this.itemArr = new TimeAreaItemClass[itemcount];
                for (int i = 0; i < this.itemArr.Length; i++)
                {
                    this.itemArr[i] = new TimeAreaItemClass() { Value = i };
                }
                this.Scroll = new TimeAreaScrollClass();
            }

            /// <summary>
            ///  区域Rect
            /// </summary>
            public RectangleF Rect { get; set; }

            /// <summary>
            /// 区域选项列表
            /// </summary>
            internal TimeAreaItemClass[] itemArr { get; set; }

            /// <summary>
            /// 区域滚动条
            /// </summary>
            internal TimeAreaScrollClass Scroll { get; set; }
        }

        /// <summary>
        /// 时间选项
        /// </summary>
        internal class TimeAreaItemClass
        {
            /// <summary>
            /// 选项rect
            /// </summary>
            public Rectangle Rect { get; set; }

            /// <summary>
            /// 选项值
            /// </summary>
            public int Value { get; set; }
        }

        /// <summary>
        /// 时间滚动条
        /// </summary>
        internal class TimeAreaScrollClass
        {
            #region 属性

            /// <summary>
            /// 滚动条背景.rect
            /// </summary>
            public RectangleF Scroll_Back_Rect { get; set; }

            /// <summary>
            /// 滚动条滑块.rect
            /// </summary>
            public RectangleF Scroll_Slide_Rect { get; set; }

            /// <summary>
            /// 内容显示区rect
            /// </summary>
            public RectangleF Owner_Display_Rect { get; set; }

            /// <summary>
            /// 内容真实区rect
            /// </summary>
            public RectangleF Owner_Content_Rect { get; set; }

            #endregion

            #region 公开方法

            /// <summary>
            /// 判断是否需要更新滚动条UI根据滚动条滑块偏移量
            /// </summary>
            /// <param name="offset">滚动条滑块偏移量</param>
            /// <returns>是否要刷新</returns>
            public bool IsResetScrollByOffset(int offset)
            {
                float y = this.Scroll_Slide_Rect.Y + offset;
                if (y < this.Scroll_Back_Rect.Y)
                    y = this.Scroll_Back_Rect.Y;
                if (y > this.Scroll_Back_Rect.Bottom - this.Scroll_Slide_Rect.Height)
                    y = this.Scroll_Back_Rect.Bottom - this.Scroll_Slide_Rect.Height;

                if (this.Scroll_Slide_Rect.Y != y)
                {
                    this.Scroll_Slide_Rect = new RectangleF(this.Scroll_Slide_Rect.X, y, this.Scroll_Slide_Rect.Width, this.Scroll_Slide_Rect.Height);
                    return true;
                }
                else
                {
                    return false;
                }
            }

            #endregion
        }

        /// <summary>
        /// 底部工具栏面板选项
        /// </summary>
        internal class BottomBarItemClass
        {
            /// <summary>
            /// 底部工具栏选项rect
            /// </summary>
            public Rectangle Rect { get; set; }

            /// <summary>
            ///底部工具栏选项文本
            /// </summary>
            public string Text { get; set; }

            /// <summary>
            /// 底部工具栏选项按钮图形路径
            /// </summary>
            public Point[] LinePointArr { get; set; }
        }

        #endregion

        #region 外观

        public class StyleAppearanceObject : AppearanceObjectBase
        {
            internal StyleAppearanceObject(ISkinObject owner, AppearanceObjectBase parent) : base(owner, parent) { }

            #region 属性

            private Color skinActivateColor = Color.Empty;
            private readonly Color defaultActivateColor = SystemColors.ControlText;
            private Color activateColor = Color.Empty;
            /// <summary>
            /// 控件激活的虚线框颜色
            /// </summary>
            [Description("控件激活的虚线框颜色")]
            [PropertyOrder(-200)]
            [SkinProperty(true, false)]
            public Color ActivateColor
            {
                get
                {
                    if (this.owner.GetSkinObjectSkinStateCore())
                    {
                        return this.skinActivateColor;
                    }

                    if (this.activateColor != Color.Empty)
                    {
                        return this.activateColor;
                    }

                    return this.defaultActivateColor;
                }
                set
                {
                    if (this.activateColor == value)
                        return;

                    this.activateColor = value;
                    this.Invalidate();
                }
            }
            private bool ShouldSerializeActivateColor()
            {
                return this.activateColor != Color.Empty;
            }
            private void ResetActivateColor()
            {
                this.activateColor = Color.Empty;
                this.Invalidate();
            }

            private Color skinBorderColor = Color.Empty;
            private readonly Color defaultBorderColor = SystemColors.GradientActiveCaption;
            private Color borderColor = Color.Empty;
            /// <summary>
            /// 边框颜色
            /// </summary>
            [Description(" 边框颜色")]
            [PropertyOrder(-198)]
            [SkinProperty(true, false)]
            public Color BorderColor
            {
                get
                {
                    if (this.owner.GetSkinObjectSkinStateCore())
                    {
                        return this.skinBorderColor;
                    }

                    if (this.borderColor != Color.Empty)
                    {
                        return this.borderColor;
                    }

                    return this.defaultBorderColor;
                }
                set
                {
                    if (this.borderColor == value)
                        return;

                    this.borderColor = value;
                    this.Invalidate();
                }
            }
            private bool ShouldSerializeBorderColor()
            {
                return this.borderColor != Color.Empty;
            }
            private void ResetBorderColor()
            {
                this.borderColor = Color.Empty;
                this.Invalidate();
            }

            private Color skinBackColor = Color.Empty;
            private readonly Color defaultBackColor = SystemColors.Window;
            private Color backColor = Color.Empty;
            /// <summary>
            /// 主面板背景颜色
            /// </summary>
            [Description("主面板背景颜色")]
            [PropertyOrder(-196)]
            [SkinProperty(true, false)]
            public Color BackColor
            {
                get
                {
                    if (this.owner.GetSkinObjectSkinStateCore())
                    {
                        return this.skinBackColor;
                    }

                    if (this.backColor != Color.Empty)
                    {
                        return this.backColor;
                    }

                    return this.defaultBackColor;
                }
                set
                {
                    if (this.backColor == value)
                        return;

                    this.backColor = value;
                    this.Invalidate();
                }
            }
            private bool ShouldSerializeBackColor()
            {
                return this.backColor != Color.Empty;
            }
            private void ResetBackColor()
            {
                this.backColor = Color.Empty;
                this.Invalidate();
            }

            private Color skinCrossLineColor = Color.Empty;
            private readonly Color defaultCrossLineColor = SystemColors.ControlLight;
            private Color crossLineColor = Color.Empty;
            /// <summary>
            /// 分割线颜色
            /// </summary>
            [Description("分割线颜色")]
            [PropertyOrder(-195)]
            [SkinProperty(true, false)]
            public Color CrossLineColor
            {
                get
                {
                    if (this.owner.GetSkinObjectSkinStateCore())
                    {
                        return this.skinCrossLineColor;
                    }

                    if (this.crossLineColor != Color.Empty)
                    {
                        return this.crossLineColor;
                    }

                    return this.defaultCrossLineColor;
                }
                set
                {
                    if (this.crossLineColor == value)
                        return;

                    this.crossLineColor = value;
                    this.Invalidate();
                }
            }
            private bool ShouldSerializeCrossLineColor()
            {
                return this.crossLineColor != Color.Empty;
            }
            private void ResetCrossLineColor()
            {
                this.crossLineColor = Color.Empty;
                this.Invalidate();
            }

            private TopBarAppearanceObject topBar;
            /// <summary>
            /// 顶部工具栏
            /// </summary>
            [Description("顶部工具栏")]
            [PropertyOrder(-194)]
            [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
            [SkinProperty(true, false)]
            public TopBarAppearanceObject TopBar
            {
                get
                {
                    if (this.topBar == null)
                        this.topBar = new TopBarAppearanceObject(this.owner, this);
                    return this.topBar;
                }
            }

            private DateAppearanceObject date;
            /// <summary>
            /// 日期主面板
            /// </summary>
            [Description("日期主面板")]
            [PropertyOrder(-192)]
            [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
            [SkinProperty(true, false)]
            public DateAppearanceObject Date
            {
                get
                {
                    if (this.date == null)
                        this.date = new DateAppearanceObject(this.owner, this);
                    return this.date;
                }
            }

            private BottomBarAppearanceObject bottomBar;
            /// <summary>
            /// 底部工具栏
            /// </summary>
            [Description("底部工具栏")]
            [PropertyOrder(-190)]
            [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
            [SkinProperty(true, false)]
            public BottomBarAppearanceObject BottomBar
            {
                get
                {
                    if (this.bottomBar == null)
                        this.bottomBar = new BottomBarAppearanceObject(this.owner, this);
                    return this.bottomBar;
                }
            }

            private ScrollBarAppearanceObject scrollBar;
            /// <summary>
            /// 滚动条
            /// </summary>
            [Description("滚动条")]
            [PropertyOrder(-186)]
            [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
            [SkinProperty(true, false)]
            public ScrollBarAppearanceObject ScrollBar
            {
                get
                {
                    if (this.scrollBar == null)
                        this.scrollBar = new ScrollBarAppearanceObject(this.owner, this);
                    return this.scrollBar;
                }
            }

            #endregion

            public class TopBarAppearanceObject : AppearanceObjectBase
            {
                internal TopBarAppearanceObject(ISkinObject owner, AppearanceObjectBase parent) : base(owner, parent) { }

                #region 属性

                private Color skinBackColor = Color.Empty;
                private readonly Color defaultBackColor = SystemColors.GradientActiveCaption;
                private Color backColor = Color.Empty;
                /// <summary>
                /// 顶部工具栏背景颜色
                /// </summary>
                [Description("顶部工具栏背景颜色")]
                [PropertyOrder(-158)]
                [SkinProperty(true, false)]
                public Color BackColor
                {
                    get
                    {
                        if (this.owner.GetSkinObjectSkinStateCore())
                        {
                            return this.skinBackColor;
                        }

                        if (this.backColor != Color.Empty)
                        {
                            return this.backColor;
                        }

                        return this.defaultBackColor;
                    }
                    set
                    {
                        if (this.backColor == value)
                            return;

                        this.backColor = value;
                        this.Invalidate();
                    }
                }
                private bool ShouldSerializeBackColor()
                {
                    return this.backColor != Color.Empty;
                }
                private void ResetBackColor()
                {
                    this.backColor = Color.Empty;
                    this.Invalidate();
                }

                private ButtonAppearanceObject button;
                /// <summary>
                /// 按钮
                /// </summary>
                [Description("按钮")]
                [PropertyOrder(-152)]
                [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
                [SkinProperty(true, false)]
                public ButtonAppearanceObject Button
                {
                    get
                    {
                        if (this.button == null)
                            this.button = new ButtonAppearanceObject(this.owner, this);
                        return this.button;
                    }
                }

                #endregion

                public class ButtonAppearanceObject : AppearanceObjectBase
                {
                    internal ButtonAppearanceObject(ISkinObject owner, AppearanceObjectBase parent) : base(owner, parent) { }

                    #region 属性

                    private ItemAppearanceObject normal;
                    /// <summary>
                    /// 正常状态
                    /// </summary>
                    [Description("正常状态")]
                    [PropertyOrder(-194)]
                    [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
                    [SkinProperty(true, false)]
                    public ItemAppearanceObject Normal
                    {
                        get
                        {
                            if (this.normal == null)
                                this.normal = new ItemAppearanceObject(this.owner, this, SystemColors.Window);
                            return this.normal;
                        }
                    }

                    private ItemAppearanceObject enter;
                    /// <summary>
                    /// 鼠标进入状态
                    /// </summary>
                    [Description("鼠标进入状态")]
                    [PropertyOrder(-192)]
                    [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
                    [SkinProperty(true, false)]
                    public ItemAppearanceObject Enter
                    {
                        get
                        {
                            if (this.enter == null)
                                this.enter = new ItemAppearanceObject(this.owner, this, SystemColors.Info);
                            return this.enter;
                        }
                    }

                    #endregion

                    public class ItemAppearanceObject : AppearanceObjectBase
                    {
                        internal ItemAppearanceObject(ISkinObject owner, AppearanceObjectBase parent, Color foreColor) : base(owner, parent)
                        {
                            this.defaultForeColor = foreColor;
                        }

                        #region 属性

                        private Color skinForeColor = Color.Empty;
                        private readonly Color defaultForeColor = Color.Empty;
                        private Color foreColor = Color.Empty;
                        /// <summary>
                        /// 前景颜色
                        /// </summary>
                        [Description("前景颜色")]
                        [PropertyOrder(-187)]
                        [SkinProperty(true, false)]
                        public Color ForeColor
                        {
                            get
                            {
                                if (this.owner.GetSkinObjectSkinStateCore())
                                {
                                    return this.skinForeColor;
                                }

                                if (this.foreColor != Color.Empty)
                                {
                                    return this.foreColor;
                                }

                                return this.defaultForeColor;
                            }
                            set
                            {
                                if (this.foreColor == value)
                                    return;

                                this.foreColor = value;
                                this.Invalidate();
                            }
                        }
                        private bool ShouldSerializeForeColor()
                        {
                            return this.foreColor != Color.Empty;
                        }
                        private void ResetForeColor()
                        {
                            this.foreColor = Color.Empty;
                            this.Invalidate();
                        }

                        #endregion

                    }

                }

            }

            public class DateAppearanceObject : AppearanceObjectBase
            {
                internal DateAppearanceObject(ISkinObject owner, AppearanceObjectBase parent) : base(owner, parent) { }

                #region 属性

                private Color skinTitleTextColor = Color.Empty;
                private readonly Color defaultTitleTextColor = SystemColors.MenuHighlight;
                private Color titleTextColor = Color.Empty;
                /// <summary>
                /// 日期面板日期标题字体颜色
                /// </summary>
                [Description("日期面板日期标题字体颜色")]
                [PropertyOrder(-198)]
                [SkinProperty(true, false)]
                public Color TitleTextColor
                {
                    get
                    {
                        if (this.owner.GetSkinObjectSkinStateCore())
                        {
                            return this.skinTitleTextColor;
                        }

                        if (this.titleTextColor != Color.Empty)
                        {
                            return this.titleTextColor;
                        }

                        return this.defaultTitleTextColor;
                    }
                    set
                    {
                        if (this.titleTextColor == value)
                            return;

                        this.titleTextColor = value;
                        this.Invalidate();
                    }
                }
                private bool ShouldSerializeTitleTextColor()
                {
                    return this.titleTextColor != Color.Empty;
                }
                private void ResetTitleTextColor()
                {
                    this.titleTextColor = Color.Empty;
                    this.Invalidate();
                }

                private ItemAppearanceObject normal;
                /// <summary>
                /// 正常状态
                /// </summary>
                [Description("正常状态")]
                [PropertyOrder(-196)]
                [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
                [SkinProperty(true, false)]
                public ItemAppearanceObject Normal
                {
                    get
                    {
                        if (this.normal == null)
                            this.normal = new ItemAppearanceObject(this.owner, this, Color.Empty, SystemColors.ActiveCaption);
                        return this.normal;
                    }
                }

                private ItemAppearanceObject enter;
                /// <summary>
                /// 鼠标进入状态
                /// </summary>
                [Description("鼠标进入状态")]
                [PropertyOrder(-194)]
                [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
                [SkinProperty(true, false)]
                public ItemAppearanceObject Enter
                {
                    get
                    {
                        if (this.enter == null)
                            this.enter = new ItemAppearanceObject(this.owner, this, SystemColors.GradientActiveCaption, SystemColors.ButtonHighlight);
                        return this.enter;
                    }
                }

                private ItemAppearanceObject selected;
                /// <summary>
                /// 已选中状态
                /// </summary>
                [Description("已选中状态")]
                [PropertyOrder(-192)]
                [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
                [SkinProperty(true, false)]
                public ItemAppearanceObject Selected
                {
                    get
                    {
                        if (this.selected == null)
                            this.selected = new ItemAppearanceObject(this.owner, this, SystemColors.GradientActiveCaption, SystemColors.ButtonHighlight);
                        return this.selected;
                    }
                }

                private ItemAppearanceObject disabled;
                /// <summary>
                /// 禁用状态
                /// </summary>
                [Description("禁用状态")]
                [PropertyOrder(-188)]
                [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
                [SkinProperty(true, false)]
                public ItemAppearanceObject Disabled
                {
                    get
                    {
                        if (this.disabled == null)
                            this.disabled = new ItemAppearanceObject(this.owner, this, Color.Empty, SystemColors.GrayText);
                        return this.disabled;
                    }
                }

                private ItemAppearanceObject unCurrent;
                /// <summary>
                /// 非本月状态
                /// </summary>
                [Description("非本月状态")]
                [PropertyOrder(-186)]
                [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
                [SkinProperty(true, false)]
                public ItemAppearanceObject UnCurrent
                {
                    get
                    {
                        if (this.unCurrent == null)
                            this.unCurrent = new ItemAppearanceObject(this.owner, this, Color.Empty, SystemColors.InactiveCaption);
                        return this.unCurrent;
                    }
                }

                #endregion

                public class ItemAppearanceObject : AppearanceObjectBase
                {
                    internal ItemAppearanceObject(ISkinObject owner, AppearanceObjectBase parent, Color backColor, Color textColor) : base(owner, parent)
                    {
                        this.defaultBackColor = backColor;
                        this.defaultTextColor = textColor;
                    }

                    #region 属性

                    private Color skinBackColor = Color.Empty;
                    private readonly Color defaultBackColor = Color.Empty;
                    private Color backColor = Color.Empty;
                    /// <summary>
                    /// 背景颜色
                    /// </summary>
                    [Description("背景颜色")]
                    [PropertyOrder(-158)]
                    [SkinProperty(true, false)]
                    public Color BackColor
                    {
                        get
                        {
                            if (this.owner.GetSkinObjectSkinStateCore())
                            {
                                return this.skinBackColor;
                            }

                            if (this.backColor != Color.Empty)
                            {
                                return this.backColor;
                            }

                            return this.defaultBackColor;
                        }
                        set
                        {
                            if (this.backColor == value)
                                return;

                            this.backColor = value;
                            this.Invalidate();
                        }
                    }
                    private bool ShouldSerializeBackColor()
                    {
                        return this.backColor != Color.Empty;
                    }
                    private void ResetBackColor()
                    {
                        this.backColor = Color.Empty;
                        this.Invalidate();
                    }

                    private Color skinTextColor = Color.Empty;
                    private readonly Color defaultTextColor = Color.Empty;
                    private Color textColor = Color.Empty;
                    /// <summary>
                    /// 文本颜色
                    /// </summary>
                    [Description("文本颜色")]
                    [PropertyOrder(-157)]
                    [SkinProperty(true, false)]
                    public Color TextColor
                    {
                        get
                        {
                            if (this.owner.GetSkinObjectSkinStateCore())
                            {
                                return this.skinTextColor;
                            }

                            if (this.textColor != Color.Empty)
                            {
                                return this.textColor;
                            }

                            return this.defaultTextColor;
                        }
                        set
                        {
                            if (this.textColor == value)
                                return;

                            this.textColor = value;
                            this.Invalidate();
                        }
                    }
                    private bool ShouldSerializeTextColor()
                    {
                        return this.textColor != Color.Empty;
                    }
                    private void ResetTextColor()
                    {
                        this.textColor = Color.Empty;
                        this.Invalidate();
                    }

                    #endregion

                }

            }
            public class BottomBarAppearanceObject : AppearanceObjectBase
            {
                internal BottomBarAppearanceObject(ISkinObject owner, AppearanceObjectBase parent) : base(owner, parent) { }

                #region 属性

                private Color skinBackColor = Color.Empty;
                private readonly Color defaultBackColor = SystemColors.GradientActiveCaption;
                private Color backColor = Color.Empty;
                /// <summary>
                /// 底部工具栏背景颜色
                /// </summary>
                [Description("底部工具栏背景颜色")]
                [PropertyOrder(-198)]
                [SkinProperty(true, false)]
                public Color BackColor
                {
                    get
                    {
                        if (this.owner.GetSkinObjectSkinStateCore())
                        {
                            return this.skinBackColor;
                        }

                        if (this.backColor != Color.Empty)
                        {
                            return this.backColor;
                        }

                        return this.defaultBackColor;
                    }
                    set
                    {
                        if (this.backColor == value)
                            return;

                        this.backColor = value;
                        this.Invalidate();
                    }
                }
                private bool ShouldSerializeBackColor()
                {
                    return this.backColor != Color.Empty;
                }
                private void ResetBackColor()
                {
                    this.backColor = Color.Empty;
                    this.Invalidate();
                }

                private Color skinMinMaxTipColor = Color.Empty;
                private readonly Color defaultMinMaxTipColor = SystemColors.MenuHighlight;
                private Color minMaxTipColor = Color.Empty;
                /// <summary>
                /// 日期最小最大限制提示字体颜色
                /// </summary>
                [Description("日期最小最大限制提示字体颜色")]
                [PropertyOrder(-195)]
                [SkinProperty(true, false)]
                public Color MinMaxTipColor
                {
                    get
                    {
                        if (this.owner.GetSkinObjectSkinStateCore())
                        {
                            return this.skinMinMaxTipColor;
                        }

                        if (this.minMaxTipColor != Color.Empty)
                        {
                            return this.minMaxTipColor;
                        }

                        return this.defaultMinMaxTipColor;
                    }
                    set
                    {
                        if (this.minMaxTipColor == value)
                            return;

                        this.minMaxTipColor = value;
                        this.Invalidate();
                    }
                }
                private bool ShouldSerializeMinMaxTipColor()
                {
                    return this.minMaxTipColor != Color.Empty;
                }
                private void ResetMinMaxTipColor()
                {
                    this.minMaxTipColor = Color.Empty;
                    this.Invalidate();
                }

                private ButtonAppearanceObject button;
                /// <summary>
                /// 按钮
                /// </summary>
                [Description("按钮")]
                [PropertyOrder(-192)]
                [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
                [SkinProperty(true, false)]
                public ButtonAppearanceObject Button
                {
                    get
                    {
                        if (this.button == null)
                            this.button = new ButtonAppearanceObject(this.owner, this);
                        return this.button;
                    }
                }

                #endregion

                public class ButtonAppearanceObject : AppearanceObjectBase
                {
                    internal ButtonAppearanceObject(ISkinObject owner, AppearanceObjectBase parent) : base(owner, parent) { }

                    #region 属性

                    private ItemAppearanceObject normal;
                    /// <summary>
                    /// 正常状态
                    /// </summary>
                    [Description("正常状态")]
                    [PropertyOrder(-194)]
                    [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
                    [SkinProperty(true, false)]
                    public ItemAppearanceObject Normal
                    {
                        get
                        {
                            if (this.normal == null)
                                this.normal = new ItemAppearanceObject(this.owner, this, SystemColors.ActiveCaption, SystemColors.Window);
                            return this.normal;
                        }
                    }

                    private ItemAppearanceObject enter;
                    /// <summary>
                    /// 鼠标进入状态
                    /// </summary>
                    [Description("鼠标进入状态")]
                    [PropertyOrder(-192)]
                    [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
                    [SkinProperty(true, false)]
                    public ItemAppearanceObject Enter
                    {
                        get
                        {
                            if (this.enter == null)
                                this.enter = new ItemAppearanceObject(this.owner, this, SystemColors.GradientInactiveCaption, SystemColors.Window);
                            return this.enter;
                        }
                    }

                    #endregion

                    public class ItemAppearanceObject : AppearanceObjectBase
                    {
                        internal ItemAppearanceObject(ISkinObject owner, AppearanceObjectBase parent, Color backColor, Color textColor) : base(owner, parent)
                        {
                            this.defaultBackColor = backColor;
                            this.defaultTextColor = textColor;
                        }

                        #region 属性

                        private Color skinBackColor = Color.Empty;
                        private readonly Color defaultBackColor = Color.Empty;
                        private Color backColor = Color.Empty;
                        /// <summary>
                        /// 背景颜色
                        /// </summary>
                        [Description("背景颜色")]
                        [PropertyOrder(-158)]
                        [SkinProperty(true, false)]
                        public Color BackColor
                        {
                            get
                            {
                                if (this.owner.GetSkinObjectSkinStateCore())
                                {
                                    return this.skinBackColor;
                                }

                                if (this.backColor != Color.Empty)
                                {
                                    return this.backColor;
                                }

                                return this.defaultBackColor;
                            }
                            set
                            {
                                if (this.backColor == value)
                                    return;

                                this.backColor = value;
                                this.Invalidate();
                            }
                        }
                        private bool ShouldSerializeBackColor()
                        {
                            return this.backColor != Color.Empty;
                        }
                        private void ResetBackColor()
                        {
                            this.backColor = Color.Empty;
                            this.Invalidate();
                        }

                        private Color skinTextColor = Color.Empty;
                        private readonly Color defaultTextColor = Color.Empty;
                        private Color textColor = Color.Empty;
                        /// <summary>
                        /// 文本颜色
                        /// </summary>
                        [Description("文本颜色")]
                        [PropertyOrder(-157)]
                        [SkinProperty(true, false)]
                        public Color TextColor
                        {
                            get
                            {
                                if (this.owner.GetSkinObjectSkinStateCore())
                                {
                                    return this.skinTextColor;
                                }

                                if (this.textColor != Color.Empty)
                                {
                                    return this.textColor;
                                }

                                return this.defaultTextColor;
                            }
                            set
                            {
                                if (this.textColor == value)
                                    return;

                                this.textColor = value;
                                this.Invalidate();
                            }
                        }
                        private bool ShouldSerializeTextColor()
                        {
                            return this.textColor != Color.Empty;
                        }
                        private void ResetTextColor()
                        {
                            this.textColor = Color.Empty;
                            this.Invalidate();
                        }

                        #endregion

                    }

                }
            }

            public class ScrollBarAppearanceObject : AppearanceObjectBase
            {
                internal ScrollBarAppearanceObject(ISkinObject owner, AppearanceObjectBase parent) : base(owner, parent) { }

                #region 属性

                private Color skinTrackBackColor = Color.Empty;
                private readonly Color defaultTrackBackColor = SystemColors.ScrollBar;
                private Color trackBackColor = Color.Empty;
                /// <summary>
                /// 轨道背景颜色
                /// </summary>
                [Description("轨道背景颜色")]
                [PropertyOrder(-139)]
                [SkinProperty(true, false)]
                public Color TrackBackColor
                {
                    get
                    {
                        if (this.owner.GetSkinObjectSkinStateCore())
                        {
                            return this.skinTrackBackColor;
                        }

                        if (this.trackBackColor != Color.Empty)
                        {
                            return this.trackBackColor;
                        }

                        return this.defaultTrackBackColor;
                    }
                    set
                    {
                        if (this.trackBackColor == value)
                            return;

                        this.trackBackColor = value;
                        this.Invalidate();
                    }
                }
                private bool ShouldSerializeTrackBackColor()
                {
                    return this.trackBackColor != Color.Empty;
                }
                private void ResetTrackBackColor()
                {
                    this.trackBackColor = Color.Empty;
                    this.Invalidate();
                }

                private Color skinThumbBackColor = Color.Empty;
                private readonly Color defaultThumbBackColor = SystemColors.WindowFrame;
                private Color thumbBackColor = Color.Empty;
                /// <summary>
                /// 拇指背景颜色
                /// </summary>
                [Description("拇指背景颜色")]
                [PropertyOrder(-134)]
                [SkinProperty(true, false)]
                public Color ThumbBackColor
                {
                    get
                    {
                        if (this.owner.GetSkinObjectSkinStateCore())
                        {
                            return this.skinThumbBackColor;
                        }

                        if (this.thumbBackColor != Color.Empty)
                        {
                            return this.thumbBackColor;
                        }

                        return this.defaultThumbBackColor;
                    }
                    set
                    {
                        if (this.thumbBackColor == value)
                            return;

                        this.thumbBackColor = value;
                        this.Invalidate();
                    }
                }
                private bool ShouldSerializeThumbBackColor()
                {
                    return this.thumbBackColor != Color.Empty;
                }
                private void ResetThumbBackColor()
                {
                    this.thumbBackColor = Color.Empty;
                    this.Invalidate();
                }

                #endregion

            }

        }


        #endregion

    }

}
